acts as soft deletable plugin

Plugin details

This plugin provides the ability to soft delete ActiveRecord models. When models are destroyed, they will be archived into a special deleted table. They can later be restored easily.

Websitehttp://github.com/ajh/acts_as_soft_deletable/tree/master Repositoryhttp://github.com/ajh/acts_as_soft_deletable/tree/master Author Andy Hartford Tags Destroy, disable, active_record, model, archive, delete LicenseLGPL

Documentation

Install the plugin:
ruby script/plugin install http://github.com/ajh/acts_as_soft_deletable/tree/master

class Artist < ActiveRecord::Base

 acts_as_soft_deletable # This will wrap the destroy method to provide soft delete
                         # support and create a new ActiveRecord class called Artist::Deleted
end



model = Artist.find(34)
model.destroy # removes row from artists table, and adds a row to
                # deleted_artists table



deleted = Artist::Deleted.find(34)
deleted.undestroy! # adds the row back to the artists table, and removes
                    # if from the deleted_artists table



restored = Artist.find(34) # The artist is restored with all the same
                           # information. The updated_at column will be
                           # Time.now if it exists.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (1 older version) | Last edited by: scott, 6 months ago