# Names scopes and boolean methods

**URL:** <https://www.ruby-forum.com/t/names-scopes-and-boolean-methods/138384>\
**Category:** Rails\
**Created:** [May 22, 2008, 2:26pm UTC](https://www.ruby-forum.com/t/names-scopes-and-boolean-methods/138384 "2008-05-22T14:26:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gareth\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@Gareth\_A](https://www.ruby-forum.com/u/Gareth_A)\
**Post date:** [May 22, 2008, 2:26pm UTC](https://www.ruby-forum.com/t/names-scopes-and-boolean-methods/138384/1 "2008-05-22T14:26:59Z")

</div>

Hi,

We’re exploring the new world of named scopes (hooray) and wondered  
about some functionality.

If I have for example

named\_scope :foo, :conditions =\> {:bar =\> true, :quux =\> 2}

which obviously creates a Model.foo method, would it be possible to  
automatically generate a method Model#foo? which told you whether an  
instance of that model was a member of the Model.foo collection?

The idea is that the named scope would let you do things like

model Article  
named\_scope :published, :conditions =\> { :some =\> :conditions }  
end

@article = Article.published.first # for the entire model  
@article.published? # for any given article

Is there any reason this wouldn’t be possible?\>

Thanks,  
Gareth
