Filtering all find methods so expired records not returned


#1

Is there a way to filter all finder methods on a model so that all
records where the expired column=1 are not returned??

Thanks
Chris


#2

Hey Chris,

Check out acts_as_paranoid [1]. It’ll probably do exactly what you
need, though you may need to modify your db just a tad. If you’re
working with a legacy db and the plugin doesn’t work for you, you can
just go ahead and adapt the plugin code to work with your db.

Pat

[1] http://ar-paranoid.rubyforge.org/


#3

Chris wrote:

Is there a way to filter all finder methods on a model so that all
records where the expired column=1 are not returned??

Thanks
Chris

Model.find(:all, :conditions => ‘expired_column = 1’

Then put this in a method like:

def Model.find_all_not_expired
Model.find(:all, :conditions => ‘expired_column = 1’)
end

Joey
http://www.feedreed.com