I''m not sure I follow. Isn''t that essentially what named_scope
is for?
named_scope :active, :conditions => {:active => 1}
named_scope :inactive, :conditions => {:active => 0}
Then anytime you want the active ones use:
@my_models = MyModel.active
Or for inactive ones use:
@my_models = MyModel.inactive
Or are you talking about overiding the behavior or find(:all) to default
to filtering for active? It just seems more logical and simpler to use
name_scope the way it was intended to be used.
What am I missing here?
Marcelo Barbudas wrote:> Hi,
>
> I was wondering, is there a way to add a default named scope for a
> model?
>
> I would like all Model queries to have an "active = 1" condition.
>
> And optionally another named_scope where "active = 1 or active =
0".
>
> Cheers,
> M.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---