Rails: how to delete ActiveRecords to a recycling bin

The contenders:

acts_as_paranoid - 2005-09-17 

Creates a delete_at column and overrides finders to ignore columns with deleted_at set. Last release was 2005-12-20, about 1600 downloads. Around ~100 blog mentions.

acts_as_trashable - 2007-11-17 

Overwrites destroy to serialize the object to another table, that can later be restored. Not that much activity on rubyforge (but it’s young). Few blog mentions by non-author.

rails_undo_redo - 2008-02-18

Serializes a revision history for that table. Can support multiple actions other than delete. Falls under the category of “scary new”, not sure I’d trust it until it’s older. It also requires a lot of hand-holding with your actions. Couple of blog mentions, nothing detailed.

CONCLUSIONS

So after looking at all these packages, I settled on acts_as_paranoid. Which I couldn’t get to install (not smart enough). I ended up using acts_as_trashable, which integrated very nicely. It was mostly a one line change to my models, and then I had to build a recycle bin controller. The one issue people might have is trying to identify the object to undelete it — I had something to hook into but because the object is serialized you may have to unserialize it to do anything with it.

I might try rails_undo_redo for my next project, it looks good but too much functionality I didn’t need for the current project.

UPDATE

acts_as_trashable does not work with BetterNestedSet 

// engtech 

Text tagged as: rails plugin