many-to-one relationship

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

"Zoltán Iklódi" <ziklodi@gmail.com> 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: