Oooh, I got it.

Book.find(:all,
:page => {:size => 5, :current => params[:page]},
:joins => "LEFT JOIN book_copies ON book_copies. book_id = books.id",
:select => "books.*, count(*) as count",
:conditions => "books.id = book_copies. book_id AND books.access = 'released'",
:group => "book_copies. book_id",
:order => "count DESC",
:limit => 100)

For those who are curious, I needed to use #find instead of #find_by_sql because I'm using the paginating_find plugin (which overrides #find, and only #find, to make pagination easier).

-- Patrick

_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to