Interesting to read: http://guides.rails.info/association_basics.html#self-joins
Op 18 jun 2010, om 19:53 heeft Michael Satterwhite het volgende geschreven: > I've been googling this for the last day, and right now all I've got is > a headache. There are several articles on this - but they are not making > sense. One is using a field :association_foreign_key that I can't find > in my documentation. I admit it, I'm lost. > > Assume I have a Categories table. To make it simple, give it one field, > a name. > A category can be at the top level (no parents) > A category can be subordinate to another category (it's child - and > obviously, the first category is the parent. This is a self-referential > many-to-many. > > OK, I know that I need a join table - for grins, lets call that > Relationship with two fields: category_id and parent_id. This isn't > carved in stone. If I need another layout - and it works - I'm happy as > I can be. > > What models do I need, and how do I define these relationships? Can > anyone help here. > > Thanks much > ---Michael > -- > Posted via http://www.ruby-forum.com/. > > -- > 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 rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > 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 rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.