I have a set of models Dog that I want to created a named_scope/ default_scope so that they load in a certain order - I want to specify a list of ids 3,2,5,1,4 to load in that order. How can I do this?
Add a position column to your table and create a default scope for it.
default_scope :order => 'position'
Do remember that (currently) Rails isn’t smart enough to override the parameters in other named scopes:
default_scope :conditions => {:active => true}
named_scope :inactive, :conditions => {:active => false}
Forget it, doesn’t work. Query resolves to SELECT * from table WHERE active=true AND active=false
Best regards
Peter De Berdt