On Wed, Dec 14, 2011 at 11:12 PM, Mauro <[email protected]> wrote: > I have these models: > > Company; > Categories; > Classifications. > > A Company has many categories and a Category has many companies. > A Company for each of its own categories has a Classification. > For example: > Company-1 has Category-1 and Category-2. > Company-1 - Category-1 has Classification-III while Company-1 - > Category-2 has Classification IV. > How can I declare associations? >
Relevant documentation is here: http://guides.rubyonrails.org/association_basics.html (For similar results, google for "Rails Guides <term on interest>"). If I understand correctly, your case would be a perfect case for has_many :through (and _not_ habtm) because you need Classification attributes on each association between a Company and a Category (then the Classification table is the association table between Company and Category). Try to work out the code for your case from that documentation. If you have difficulties with it, please come back with your specific problems, showing us the code your wrote. HTH, Peter -- http://twitter.com/peter_v http://rails.vandenabeele.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 [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.

