I have a (hopefully) simple problem, but just don’t get the idea how
to implement it in rails.
There are two classes, one for users and one for comments. A user
has_many comments and each comment belongs_to user.
I tried to do something like this:
@foo = User.find(:all, :order => ‘comments_count’)
comments_count is not known. An :include => ‘comments’ also doesn’t
help (even that the SQL Syntax is doing a join now).
How can I find all Users sorted by the number of comments they have
posted? It’s enough if the resulting list only contains the count-
field as result. It is not necessary to have all comments “attached”
to the list.
Thanks in advance!