# Always ignore some records in my model

**URL:** <https://www.ruby-forum.com/t/always-ignore-some-records-in-my-model/129846>\
**Category:** Rails\
**Created:** [February 22, 2008, 12:55am UTC](https://www.ruby-forum.com/t/always-ignore-some-records-in-my-model/129846 "2008-02-22T00:55:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bcm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/977dab/32.png) [@bcm](https://www.ruby-forum.com/u/bcm)\
**Post date:** [February 22, 2008, 12:55am UTC](https://www.ruby-forum.com/t/always-ignore-some-records-in-my-model/129846/1 "2008-02-22T00:55:21Z")

</div>

Hi all,

I’ve got an interesting problem. I’m dealing with a legacy database,  
and for one of my models I always want to ignore records that have a  
particular column set. I would like to pretend like they don’t exist.  
When I run MyModel.find() I don’t want them to show in the result set.

I considered using after\_find() to do this, but that gets called on  
every item in the found collection, not the entire collection. Is there  
some easy way to modify MyModel to insert a :conditions statement (or  
modify a pre-existing one) on all queries issued by the model? Ideally  
it would be transparent enough that the other models don’t need to know  
anything about it.

Thanks!

-Brent

---

<div class="post-metadata">

**Author:** ![bcm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/977dab/32.png) [@bcm](https://www.ruby-forum.com/u/bcm)\
**Post date:** [February 22, 2008, 1:05am UTC](https://www.ruby-forum.com/t/always-ignore-some-records-in-my-model/129846/2 "2008-02-22T01:05:13Z")

</div>

> anything about it.  
> perhaps…

[http://agilewebdevelopment.com/plugins/global\_scope](http://agilewebdevelopment.com/plugins/global_scope)

Or maybe this guy wrote his idea up.

[http://zargony.com/2007/08/13/scope\_out-feature-default\_scope](http://zargony.com/2007/08/13/scope_out-feature-default_scope)

---

<div class="post-metadata">

**Author:** ![bcm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/977dab/32.png) [@bcm](https://www.ruby-forum.com/u/bcm)\
**Post date:** [February 22, 2008, 1:31am UTC](https://www.ruby-forum.com/t/always-ignore-some-records-in-my-model/129846/3 "2008-02-22T01:31:27Z")

</div>

Philip H. wrote:

> > anything about it.  
> > perhaps…
> 
> [http://agilewebdevelopment.com/plugins/global\_scope](http://agilewebdevelopment.com/plugins/global_scope)
> 
> Or maybe this guy wrote his idea up.
> 
> [Scope\_out feature: default\_scope — zargony.com](http://zargony.com/2007/08/13/scope_out-feature-default_scope)

Zargony refers to the global\_scope plugin. :+)

That happens to _perfectly_ solve my problem. Thanks for the tip!
