Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding paper_trail

  • Loading branch information...
commit 5759201d0619b5364012c05dac52613981a50489 1 parent b66753d
@chaserx chaserx authored
View
1  Gemfile
@@ -13,6 +13,7 @@ group :production do
gem 'pg'
end
+gem 'paper_trail', '~> 2'
gem 'simple_form'
gem 'devise'
View
4 Gemfile.lock
@@ -92,6 +92,9 @@ GEM
mime-types (1.19)
multi_json (1.3.6)
orm_adapter (0.0.6)
+ paper_trail (2.6.3)
+ activerecord (~> 3.0)
+ railties (~> 3.0)
pg (0.14.0)
polyamorous (0.5.0)
activerecord (~> 3.0)
@@ -158,6 +161,7 @@ DEPENDENCIES
devise
jquery-rails
meta_search (>= 1.1.0.pre)
+ paper_trail (~> 2)
pg
rails (= 3.2.6)
sass-rails (~> 3.2.3)
View
2  app/models/item.rb
@@ -1,4 +1,6 @@
class Item < ActiveRecord::Base
+ has_paper_trail
+
attr_accessible :time_checked_in, :time_checked_out, :checked_out_by,
:date_collected, :name, :tag_number, :type, :desc,
:checkedin, :checkedout, :donated_by, :maintained_by
View
18 db/migrate/20120710205016_create_versions.rb
@@ -0,0 +1,18 @@
+class CreateVersions < ActiveRecord::Migration
+ def self.up
+ create_table :versions do |t|
+ t.string :item_type, :null => false
+ t.integer :item_id, :null => false
+ t.string :event, :null => false
+ t.string :whodunnit
+ t.text :object
+ t.datetime :created_at
+ end
+ add_index :versions, [:item_type, :item_id]
+ end
+
+ def self.down
+ remove_index :versions, [:item_type, :item_id]
+ drop_table :versions
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.