I have a bunch of models defined and have created all the
relationships between them. For simplicity lets just say they’re…
class Document < ActiveRecord::Base
class Author < ActiveRecord::Base
I know I can do something like:
Document.find :all, :include => authors, conditions => ‘authors.id =
and Rails will generate SQL similar to
SELECT * FROM documents
LEFT OUTER JOIN authors_documents ON authors_documents.document_id
LEFT OUTER JOIN authors ON authors.id = authors_documents.author_id
WHERE authors.id = 5
But what if I don’t want all the author information to come back in
the query? Do I need to hand code a ‘:joins’ option or is there
another method I’m not aware of which can automatically create the SQL
joins for me?
BTW I tried using the ‘:select’ option, but it seems to ignore it.
I’ve also tried leaving off the ':include" which obviously throws an
Any help would be appreciated, thanks!