trying to do a scope in rails3.
:book has_many :chapters
I want scope :long to return books with > 10 chapters.
How best to structure
This should get you going:
class Book scope :long, joins(:chapters). select('books.id, count(chapters.id) as n_chapters'). group('books.id'). having('n_chapters > 10') end
Does it help?