Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a better version of something like acts_as_paranoid for Rails 3?

Does anyone know of a gem that both soft deletes records from a database (just flags them as deleted as opposed to is actually deleted) and...

...also when do you any type of find automatically omits those trashed records without using any special user-defined scopes. E.g. it all takes place in the gem.

Cheers!

like image 844
MintDeparture Avatar asked Jun 15 '11 08:06

MintDeparture


2 Answers

DHH is a fan of doing this with 'concerns' which are basically just module mixins and I like that minimalist approach.

Here's DHH's version - https://gist.github.com/1014971

Here's my bugfixed version - https://gist.github.com/4032984

like image 69
Tim Fletcher Avatar answered Sep 30 '22 19:09

Tim Fletcher


You might want to checkout paper_trail

https://github.com/airblade/paper_trail

like image 33
MatthewFord Avatar answered Sep 30 '22 18:09

MatthewFord