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