views:

74

answers:

2

Which solution would you prefer to use with Rails 3 in order to provide gmail like undo option instead of confirmation popups?

I would like to allow user to undo last action, which would then revert the changes in tables made by that action.

So far I was trying to get things done using Memento gem. Its not ideal, but things worked. The problem is, that this gem doesn't seem very active and it won't work with Rails. I would like to find something more elegant for Rails3.

Any ideas?

A: 

I would add a field to the model that flags it as, for example, deleted. To delete a record the delete action could set the flag as the users id and create a delayed job to delete the record in a defined length of time. The user can now undo any of their previous actions until this time has passed. To undo, reset the flag as nil and delete the delayed job. The deleted flag can be used to hide the instance from users until it is actually deleted.

mark
I do keep most of the records anyway and never delete them, but this solution is not suitable for an undo action. This way the only thing you can track is the destroy action, and I would like user to be able to undo any change they made to particular model...
mdrozdziel
+3  A: 

how about something like this http://github.com/airblade/paper_trail?

Matt Briggs
I am currently testing this one. Looks very primising, works flawlesly with Rails3 so far.
mdrozdziel
Works great, thanks!
mdrozdziel