Here is the query used in rails 2. The idea here is to obtain the top
10 widgets.
Widget.find(:all, :select => 'widget_type_id, COUNT(widget_type_id) AS
widgettypeid', :group => 'widget_type_id', :order => 'widgettypeid
DESC', :limit => 10)
This is deprecated and i want to port it to rails 3.
I'm not sure how to do the "COUNT(widget_type_id) AS widgettypeid" as
this doesn't seem to work below but it is close. hoping someone will
chime in. I'm sure I'm missing something simple.
Widget.group(:widget_type_id).select('widget_type_id,
count(widget_type_id) AS widgettypeid').order(:widgettypeid).limit(10)