I’m trying to find all of the products that have parts supplied by
the given supplier’s name:
@products=Product.find :all, :include=>[“company”,“parts”],
:joins=>“inner join suppliers_to_parts
stp on stp.part = parts.id
inner join suppliers s on s.id =
:conditions=>[“s.name = ?”,name]
The problem is that the supplier’s name is not returned, and :select
doesn’t work when :include is used.
Of course I could use all :joins, or even find_by_sql, but I’d like to
have my object hierarchy (well, as much as rails will allow) returned
instead of a single object with a bunch of attributes.
Is it possible to achieve this some other way?