Hello,
I am looking for a better way to do the following (my code examples are
crappy pseudocode):
I have two associated models, Book and Chapter, where book has_many
chapters. I want to first select several books, for example,
books_by_dr_seuss = Book.find(:all, :conditions => {:author => "Seuss"
})
Then, I want to select all the "Chapter 3"'s from this result, i.e.
Chapter 3 of Cat in the Hat, Chapter 3 of Fox in Socks, etc.
I want to do something like:
chapter_threes = Chapter.find(:all, :include=>[:book], :conditions =>
{chapter.book in books_by_dr_seuss } )
How would I do this without resorting to something like "select * from
chapters where chapter.book_id=1 or chapter.book_id=2, etc"?
Thanks for your help.
A
--
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
-~----------~----~----~----~------~----~------~--~---