Dave
Dave

Reputation: 783

Order By Count Query

I have the following code which retrieves the count of the following query:

<% @count = Model.find(:all, :conditions =>
              {:action => actions, :controller => tempController}).count %>

I'm just wondering how I get this query to order by the count retrieved going from highest to lowest.

Upvotes: 1

Views: 102

Answers (1)

Sachin R
Sachin R

Reputation: 11876

Calling Model from views is just against the MVC. This is the wrong way

<% @count = Model.where({:action => actions, 
                         :controller => tempController}).order("column_name").count %>

Upvotes: 2

Related Questions