Parent has_many :children scope :primary, where(:role => 'primary') Or something like that. The syntax of scope, or named_scope differs depending on the version of Rails, but you get the idea... You'll probably want to add code to make sure that only one child has the primary role for a particular parent.
HTH On Oct 4, 2010, at 9:15 AM, JoshK wrote: > Hi I have a table where I need to identify one of the children as the > "prime" child. > > So, its like: > > Parent > has_many :Child > has_one: Child :as :prime_child (?) > > or something like that? Do I put something like prime_child_id in the > Parent table? > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" 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/rubyonrails-talk?hl=en. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" 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/rubyonrails-talk?hl=en.

