Don't delete your records, move them to a different table
Switch branches/tags
Nothing to show
Latest commit 9778feb Jan 7, 2013 @winton Update
Failed to load latest commit information.
bin Merge branch 'rails' of Feb 4, 2010
config Version 0.4.1 Nov 21, 2011
lib tables may also be escaped with " Jan 30, 2011
spec Moving ActsAsArchive configuration to YAML file (config/acts_as_archi… Jan 26, 2011
.gitignore Working on framework fixtures Dec 29, 2010
LICENSE Merge branch 'rails' of Dec 29, 2010 Update Jan 7, 2013
Rakefile Merge branch 'rails' of Jan 10, 2011
acts_as_archive.gemspec Merge branch 'rails' of Jan 10, 2011
init.rb Removing extraneous Require call Feb 7, 2010


This project is no longer maintained. If you would like to become the new owner, please email Winton Welsh.

Don't delete your records, move them to a different table.

Like acts_as_paranoid, but doesn't mess with your SQL queries.


gem install acts_as_archive

Rails 2


config.gem 'acts_as_archive'

Rails 3


gem 'acts_as_archive'


require 'acts_as_archive'

class Application < Sinatra::Base
  include ActsAsArchive::Adapters::Sinatra


Create config/acts_as_archive.yml to define the archive class and archive table for each of your models:

  - class: Article::Archive
    table: archived_articles

It is expected that neither the archive class or archive table exist yet. ActsAsArchive will create these automatically.


Run rake db:migrate. Your archive table is created automatically.

That's it!

Use destroy, destroy_all, delete, and delete_all like you normally would.

Records move into the archive table instead of being destroyed.

Automatically archive relationships

If your model's relationship has the :dependent option, and the relationship also uses acts_as_archive, that relationship will archive automatically.

What if my schema changes?

New migrations are automatically applied to the archive table.

No action is necessary on your part.

Query the archive

Use the archive class you specified in the configuration:


Delete records without archiving

Use any of the destroy methods, but add a bang (!):

Article.delete_all!([ "id in (?)", [ 1, 2, 3 ] ])

Restore from the archive

Use any of the destroy/delete methods on the archived record to move it back to its original table:

Article::Archive.delete_all([ "id in (?)", [ 1, 2, 3 ] ])

Any relationships that were automatically archived will be restored as well.

Magic columns

You will find an extra deleted_at datetime column on the archive table.

You may manually add a restored_at datetime column to the origin table if you wish to store restoration time as well.

Migrate from acts_as_paranoid

Add this line to a migration, or run it via script/console:


This copies all records with non-null deleted_at values to the archive.

Running specs

There is a wiki entry that describes the development setup in-depth.