>From inside your Model class do: default_scope(:default).update(:order => [:created_at.desc])
You'd essentially be 'update'ing the default query object that all calls to all() and first() start off with before applying the user's parameters class Post include DataMapper::Resource #... other properties here default_scope(:default).update(:order => [:created_at.desc]) end === Adam French Project Manager Wieck Media On Tue, Dec 9, 2008 at 3:50 PM, cult hero <[EMAIL PROTECTED]> wrote: > > I know I can set the order of a collection when call .all() or .find() > or whatever, but is there a way to set a default sorting order? > > So, instead of it sorting by the key field by default, can I make it > so every time I get a collection back from a class that includes > DataMapper::Resource it sorts by another field. > > I found a "default_order" method, but that appears to apply to > repositories which doesn't help for what I'm trying to do. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" 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/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
