Rick Denatale wrote:
> Why not
>
> pages = Page.all(:include => :book)
I usually need to filter by, let's say, a certain library:
@pages = Page.all(
:select => 'pages.id, pages.no',
:joins => :book,
:conditions => "books.library_id = #{1}"
)
AR will generate:
SELECT pages.id, pages.no FROM "pages" INNER JOIN "books" ON "books".id
= "pages".book_id WHERE (books.library_id = 1)
So the join has already been done. Wouldn't :include make a redundant
query?
--
Posted via http://www.ruby-forum.com/.
--
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.