On 4 October 2011 21:35, Jim Burgess <li...@ruby-forum.com> wrote:
> I have the following associations in my models:
>
> item.rb
> belongs_to :manufacturer, :class_name => "Company"
> belongs_to :distributor, :class_name => "Company"
>
> company.rb
> has_many :items
>
> My question: what is the best way to find all of the items belonging to
> a specific company?

If you have a company in @company (for example) then that companies
items are @company.items.
Similarly for an @item its company is @item.company

I think you might benefit from working through some tutorials.
railstutorial.org is good and free to use online.

I say that assuming that you have already worked through the Rails Guides.

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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to