On Oct 14, 12:38 pm, Phrogz <[email protected]> wrote:
> On Oct 14, 1:35 pm, Nate Wiger <[email protected]> wrote:
>
> > Is there a "default_scope" equivalent?
>
> > We use that alot of places to sort by date desc, or name asc, or
> > something else where we don't want to have to put it everywhere.
>
> Just create your own dataset method and use that to start with.
>
> class Account < Sequel::Model
>   def_dataset_method(:standard) do
>     order(:date.desc)
>   end
> end
>
> active_admins = Account.standard.active.admin ...

I prefer not having a scope on the Model's dataset (so I recommend
Phrogz's advice), but if you really want to:

  class Account < Sequel::Model
    self.dataset = dataset.order(:date.desc)
  end

Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" 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/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to