Hello, I want to add a Partner property to more than one type of models (ie. SalesOrder and PurchaseOrder). Is this the proper way of defining associatons or there''s a simpler way? class Partner < ActiveRecord::Base has_many :sales_orders has_many :purchase_orders end class SalesOrder < ActiveRecord::Base belongs_to :partner end class PurchaseOrder < ActiveRecord::Base belongs_to :partner end Thanks Zoltan -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
"Zoltán Iklódi" <ziklodi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote in post #1054400:> Hello, > > I want to add a Partner property to more than one type of models (ie. > SalesOrder and PurchaseOrder). > Is this the proper way of defining associatons or there''s a simpler > way?What you need here is a polymorphic association. See: http://guides.rubyonrails.org/association_basics.html#polymorphic-associations -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.