On Aug 22, 9:58 am, Christopher Krailo <[email protected]> wrote: > I didn't see any paranoid delete plugins and Googling didn't turn up > any, either. Do any of y'all know of one?
I don't think there is an existing one. > Otherwise, I'll need to figure out how the plugin system works so I > can contribute one. :) Assuming that you want to keep old records in the same table and just have a simple is_deleted flag, it should be fairly simple. Override Model#delete to do an update(:is_deleted=>true) instead of a delete, and set a default filter on the model's dataset to filter(:is_deleted=>false). There are other ways of handling things, such as basing the model off a view that filters deleted records, or having a separate table that holds the deleted records. Using a separate table is more complex, but often better for performance, but then it makes it more difficult to include both active and inactive records in the same query. Personally, in similar cases I just define a subset (usually "active"), and manually use it in all places I want only active records appearing. And I do the update manually instead of overriding delete. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
