From: Tomas Sedovic tsedovic@redhat.com
Using the Archivist gem, instances that are deleted will be moved to the `archived_instances` table instead.
They can be accessed using familiar methods on the Instance::Archive class:
Instance::Archive.find 10 Instance::Archive.find_by_name 'myapp/frontend'
Methods `delete!` and `destroy!` bypass archiving and will permanently delete the model. --- src/Gemfile | 1 + src/app/models/instance.rb | 1 + .../20110822110535_create_archived_instances.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 0 deletions(-) create mode 100644 src/db/migrate/20110822110535_create_archived_instances.rb
diff --git a/src/Gemfile b/src/Gemfile index ce11e9d..eeb11d0 100644 --- a/src/Gemfile +++ b/src/Gemfile @@ -21,6 +21,7 @@ gem 'pg' gem 'thin' gem 'json' gem 'railties' +gem 'archivist' group :development, :test do #gem 'rspec-rails' #gem 'factory_girl_rails' diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb index aee4750..9c06a30 100644 --- a/src/app/models/instance.rb +++ b/src/app/models/instance.rb @@ -59,6 +59,7 @@ require 'util/assembly_xml' require 'util/condormatic' class Instance < ActiveRecord::Base + has_archive include PermissionedObject
cattr_reader :per_page diff --git a/src/db/migrate/20110822110535_create_archived_instances.rb b/src/db/migrate/20110822110535_create_archived_instances.rb new file mode 100644 index 0000000..731710a --- /dev/null +++ b/src/db/migrate/20110822110535_create_archived_instances.rb @@ -0,0 +1,8 @@ +class CreateArchivedInstances < ActiveRecord::Migration + def self.up + Archivist.update Instance + end + + def self.down + end +end