On 1 June 2010 12:15, Tom Ha <[email protected]> wrote: > Hi there, > > What's the correct end part of "conditions" if: > > - you assume that "Book :has_many Authors" > - I'd like to have the find statement in the below format > > @books = Book.find(:all, > :joins => [:authors => [...]], > :include => :whatever_stuff, > :conditions => "books.published = TRUE AND > number-of-authors-must-be-greater-than-5") > > Thank you for your help!
I would start by getting the easy bit going (published is true), then work out the trickier part. I don't think you need the joins, but you will want to include authors I think. I have not tried it but for the number of authors have you tried a condition involving authors.count > 5? If you are not getting the results you expect look at the sql in the log and see what is wrong with it. Colin -- 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.

