I think something like the following:

book_ids = ids of selected books (as gleened from the controller)
chapter_threes = Chapter.find(:all, :include => :book, :conditions => ['book.id 
in ? and chapter.chapter_number = 3', book_ids])

obviously not tested, but once you fix any syntax errors it should work.

Simon

On Fri, 13 Mar 2009 09:46:14 +0900, Avi Ir <[email protected]> 
wrote:

>
>
> Thanks for the response Simon -- I think my example didn't fully capture
> what I am trying to do :)
>
> I want to select from a collection or list of items.  I can't use
> 'books.author like' because there is no criteria that ties them all
> together.
>
> A better example would be:
> User is presented with a list of checkboxes (let's say, book names) in a
> form.  He checks several of these checkboxes.  The form gets submitted
> and returns all of the chapters 3 from the selected books.
>
> For example say the user selects:
>
> Fox in Sock by Dr Seuss
> War and Peace by Leo Tolstoy
> The Godfather by Mario Puzo
>
> The form passes the ids of these selections (let's say, [1000, 1001,
> 1002]) to the controller, which then calls a query on these selected
> plates:
>
> selected_books = params[:selected_books]
> Chapter.find(:all, :include=>:book, :conditions => 'chapter.book_id =
> book.id and book.id in books and chapters.chapter=3' )
>
> Is there a way to do that statement?  "in books" is obviously not a
> valid command...
>
> Thanks!
> A






--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to