Ruby on Rails Friday, March 30, 2012

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@googlegroups.com.
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.

No comments:

Post a Comment