Trying again.

On 4 October 2011 21:44, Colin Law <[email protected]> wrote:
> On 4 October 2011 21:40, Colin Law <[email protected]> wrote:
>> On 4 October 2011 21:35, Jim Burgess <[email protected]> wrote:
>>> I have the following associations in my models:
>>>
>>> item.rb
>>> belongs_to :manufacturer, :class_name => "Company"

I am not sure if it is necessary but you might need :foreign_key =>
"manufacturer_id" here.  I put it in to remind me what the field is
called anyway.

>>> belongs_to :distributor, :class_name => "Company"

Same here

>>>
>>> company.rb
>>> has_many :items

Here you need two associations
has_many :manufacturer_items, :class_name => "Item"
has_many :distributor_items, :class_name => "Item"
where manufacturer_items is a name you can choose yourself.

Then for a particular company @company the items are
@company.manufacturer_items and @company.distributor_items.

Colin

-- 
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.

Reply via email to