Re-implementing acts_as_paranoid using default_scope in Rails 2.3
A few months ago Mike Gunderloy wrote 3 Plugins for Safer ActiveRecord Deletions for Rails Inside and mentioned acts_as_paranoid, a plugin that flags ActiveRecord objects as deleted without actually deleting them (this is useful if you might need to "undo" the delete later).
Now, Jeff Chupp has used Rails / ActiveRecord 2.3's default_scope feature to implement a similar feature to acts_as_paranoid in just a few lines of regular model code. He's also wrapped this up into a plugin of his own called is_paranoid.
Support from: David Berube. Is your Rails app running slow? I'm David Berube, author of Practical Reporting with Ruby and Rails, and I can help. Call me at (603)-485-9622 for a free consultation and $100 off your first project.
March 23rd, 2009 at 10:00 pm
I think both solutions - named scope and acts_as_paranoid are implemented in wrong layer. It should be handled by database, making copies, or preserving delted records with some sort of versioning. Not sure if there are any solutions out there for MySQL but I am pretty sure you can do it in Postgres or Oracle.
November 2nd, 2009 at 5:38 pm
Apparently it's dead already:
http://blog.semanticart.com/killing_is_paranoid/
November 3rd, 2009 at 9:40 pm
I was disappointed in hearing that is_paranoid was getting abandoned...I was literally a day away from implementing it in a project.