This is a unique case of the more general case (polymorphic association). In all the cases the association "translations" points from a source table to the translations table for that item. In the case of the language table for uniformity the "translations" association points from Language to Translation for the translations of the language name. The Language is also used as a reference in the Translation table for what language the translation is in. So there are 2 associations from Language to Translation. One is the same as all the other tables that are translated, and one unique association for what language the translation is in. I specify the reverse association which should resolve any ambiguity, but apparently not. I will dig into the code and see if I can resolve it.
Michael On Mar 4, 2011, at 12:59 AM, vhochstein wrote: > Hi Michael, > > that sounds a little bit complicated. > What I think I ve understood is, that you ve assigned an association a > name (translations) which is the name of another association (model > Translation) (which you gave as a consequence a new name > translation_language) ?? > > 1. Yes, I can imagine that it makes trouble. > 2. Naming looks suboptimal to me (Maybe try to avoid that name clash) > 3. If you would like to fix it, open an issue and please push an > example app to github. > > -- > Volker > > On Mar 2, 4:07 pm, Michael Latta <[email protected]> wrote: >> Ok. I am using the rails 3 jQuery fork. >> >> Michael >> >> class LanguagesController < SecureController >> before_filter :clear_page_status >> >> active_scaffold :Language do | config | >> config.columns.exclude :app_item_texts, :defaulting_users, >> :translation_language >> config.columns[:translations].association.reverse = :row >> >> infer_validations config >> >> config.columns.each { | c | c.weight = 1000 } >> config.columns[:iso_code].weight = 100 >> config.columns[:english_description].weight = 200 >> config.columns[:local_description].weight = 300 >> config.columns[:enabled].weight = 400 >> >> config.list.columns.exclude [:updated_at, :created_at, :lock_version, >> :app_item_texts, :defaulting_users, :translations] >> >> config.list.sorting = {:iso_code => :asc} >> end >> end >> >> class Language < ActiveRecord::Base >> validates_lengths_from_database >> >> has_many :app_item_texts >> has_many :defaulting_users, :foreign_key => "default_language_id", >> :class_name => "User" >> has_many :translations, :as => :row, :dependent => :destroy >> has_many :translation_language, :class_name => "Translation" >> >> validates :iso_code, :presence => true, :uniqueness => true >> validates :local_description, :presence => true >> validates :english_description, :presence => true >> validates :email_subject, :length => {:maximum => 80} >> end >> >> class Translation < ActiveRecord::Base >> validates_lengths_from_database >> >> belongs_to :row, :polymorphic => true >> belongs_to :language >> end >> >> On Mar 2, 2011, at 7:45 AM, Sergio Cambra .:: entreCables S.L. ::. wrote: >> >>> On Miércoles, 2 de Marzo de 2011 03:16:48 Michael Latta escribió: >>>> I have a model that is associated to another model. The reverse >>>> association is polymorphic. A different association between the two >>>> tables matches the name of the parent model. >> >>>> Language ---- translations ----> Translations >>>> Language <--- row ---------------- Translations >> >>>> Those are the ones I want used so "row" would be hidden as the reverse. >> >>>> Language <------ lanugage ------ Translations >> >>>> This is the one that is being hidden (as well as row being hidden). When >>>> other models are in the place of language it is working well. I set the >>>> reverse on the Language model for the translations association to "row" >>>> explicitly. >> >>>> Any suggestions on how to make it show the language association in the >>>> subform? >> >>>> Michael >> >>> Maybe it would be easy to understand with actual models >> >>> -- >>> Sergio Cambra .:: entreCables S.L. ::. >>> Mariana Pineda 23, 50.018 Zaragoza >>> T) 902 021 404 F) 976 52 98 07 E) [email protected] >> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "ActiveScaffold : Ruby on Rails plugin" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group >>> athttp://groups.google.com/group/activescaffold?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "ActiveScaffold : Ruby on Rails plugin" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/activescaffold?hl=en. > -- You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.
