Mark Chadwick on 12 Feb 2007 14:29:57 -0000 |
Hey Mat, Yeah, it pretty much does as you've described. Sorry for the shoddy documentation, I had promised the source to a couple people, and just wanted to get it out. The general idea is that it's a cleaner alternative to the acts_as_paranoid pattern that crops up so much -- ie: People are afraid to delete data from their DB, so they code ugly flags and hacks all over their code. I use this acts_as_restorable plugin like this: In my database.yml file, I have an extra "backup" setting (just like "test," "development," and "production") that hooks up to a DB with only one table. Then, I have a model like: class RestorableModel < ActiveReocrd::Base establish_connection :backup end So, the long and the short is, you throw acts_as_restorable in a model, and before it gets deleted, it serializes it and it's dependents into the RestoreableModel. The code is there to move it back as well. I use this by tying a user id to the RestorableModels as well, so I can make sure people can only see/restore what they've nuked. It works pretty well...and it gets all the crap out of your DB. I suppose, my warning if you're going to use it: It's not 100% tested, and it does some magic with primary keys. I know Postgres can handle said magic, and it looks like sqlite does too, but that's as far as I can say. -Mark _______________________________________________ To unsubscribe or change your settings, visit: http://lists.phillyonrails.org/mailman/listinfo/talk
|
|