# Default named\_scope

**URL:** <https://www.ruby-forum.com/t/default-named-scope/146426>\
**Category:** Rails\
**Created:** [August 20, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/default-named-scope/146426 "2008-08-20T23:08:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arvias](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac91a4/32.png) [@arvias](https://www.ruby-forum.com/u/arvias)\
**Post date:** [August 20, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/default-named-scope/146426/1 "2008-08-20T23:08:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![arvias](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac91a4/32.png) [@arvias](https://www.ruby-forum.com/u/arvias)\
**Post date:** [August 21, 2008, 5:20pm UTC](https://www.ruby-forum.com/t/default-named-scope/146426/2 "2008-08-21T17:20:19Z")

</div>

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 B. 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.
