Hi,

I have a topic model which has_many replies.

On my topic index page I would like to be able to sort the topics by
the number of replies.

In my topic model I have defined

Topic.rb
...
has_many :replies
....
  def total_replies
    replies.count
  end
....

And in my controller I have tried

@topics = Topic.find(:all, :conditions => ["forum_id = ?",
@forum.id], :order => "total_replies DESC")

but I get the error Mcolumn "total_replies" does not exist

I know the column doesn't exist, but the question is, how can I get
the 'total_replies' to behave as a column.

Thanks,

Dan

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