How to: manage the deleted records in Ruby on Rails

The best way to have organized deleted records, in a full functional easily restorative form in Ruby on Rails applications is to use the gem (or plugin) ActsAsArchive

Install the gem

  sudo gem install acts_as_archive

And also add in the application’s gem configuration, by adding the following line in your environment.rb


 config.gem 'acts_as_archive'

Add acts_as_archive to your models:

class Article < ActiveRecord::Base
  acts_as_archive
end

Create archive tables

Add this line to a migration as the last line of the method self.up


ActsAsArchive.update Article


Tags: , ,
This entry was posted on Thursday, July 29th, 2010 at 5:32 am and is filed under rubyonrails. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

Your comment