Forum: Ruby on Rails Filtering all find methods so expired records not returned

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris (Guest)
on 2006-02-22 08:21
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
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-02-22 08:31
(Received via mailing list)
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/
6dab365a82517fb694650a57ee88e4a4?d=identicon&s=25 joey__ (Guest)
on 2006-02-22 10:24
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
This topic is locked and can not be replied to.