sqlruby-on-railsmodeldefault-scope

How do you put multiple default scopes on on a model?


I was wondering how do you have multiple default scopes (ordering) on a model for example I have a comments model that needs ordering by both date and approved:

default_scope :order => 'approved ASC', :order => 'date ASC'

So how do you have both of these ordering put on a model, so I first orders by approved, and then by date.

Cheers!


Solution

  • Here is the good syntax for ordering with several fields :

    default_scope :order => 'approved ASC, date ASC'