No, like this:
@books = Book.find(:all, :conditions =>
[‘shelves.library_id = ?’, @library.id], :include=>{:shelf=>{:books=>:pages}}
You can nest this as much as you like. Just be aware of the slightly quirky naming conventions for the table aliases, in case you want to add conditions to the child or grandchild tables. Have a look at the Rails doco for Association.
Cheers,
Max
Carl Johnson <rails-mailing-list@...> writes:
> <at> books = Book.find(:all, :conditions =>
> ['shelves.library_id = ?', <at> library.id],
> :include=>{:shelf=>{:books=>:pages}}
>
> You can nest this as much as you like.
Ah perfect! I knew there must be a Rails way to do the joins. Thanks
very much!
Be careful though. As you join more tables together, if you don't have enough
indexing on the columns which are being joined then your queries will really
start to drag as more data is added.