Always ignore some records in my model

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

anything about it.
perhaps…

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

Philip H. wrote:

anything about it.
perhaps…

http://agilewebdevelopment.com/plugins/global_scope

Or maybe this guy wrote his idea up.

Scope_out feature: default_scope — zargony.com

Zargony refers to the global_scope plugin. :+)

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