Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding paper trail to keep track of episode and comment changes

  • Loading branch information...
commit 06b8647d011abce3140c71fca12c25d65bdf7f6e 1 parent 036fe4d
@ryanb authored
View
1  Gemfile
@@ -14,6 +14,7 @@ gem "omniauth", ">= 0.2.2"
gem "exception_notification", :git => "git://github.com/rails/exception_notification.git", :require => "exception_notifier"
gem "ancestry"
gem "cancan", :git => "git://github.com/ryanb/cancan.git", :branch => "2.0"
+gem "paper_trail"
group :development, :test do
gem "rspec-rails"
View
3  Gemfile.lock
@@ -158,6 +158,8 @@ GEM
oa-more (= 0.2.2)
oa-oauth (= 0.2.2)
oa-openid (= 0.2.2)
+ paper_trail (2.2.5)
+ rails (~> 3)
polyglot (0.3.1)
pyu-ruby-sasl (0.0.3.2)
rack (1.2.2)
@@ -251,6 +253,7 @@ DEPENDENCIES
mysql2
nifty-generators
omniauth (>= 0.2.2)
+ paper_trail
rails (= 3.0.7)
rake (= 0.8.7)
redcarpet
View
1  app/models/comment.rb
@@ -6,6 +6,7 @@ class Comment < ActiveRecord::Base
scope :recent, order("created_at DESC")
+ has_paper_trail
has_ancestry
acts_as_list :scope => :episode
View
1  app/models/episode.rb
@@ -3,6 +3,7 @@ class Episode < ActiveRecord::Base
has_many :taggings, :dependent => :destroy
has_many :tags, :through => :taggings
+ has_paper_trail
acts_as_list
scope :published, lambda { where('published_at <= ?', Time.now.utc) }
View
18 db/migrate/20110630221611_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
View
13 db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110504180955) do
+ActiveRecord::Schema.define(:version => 20110630221611) do
create_table "comments", :force => true do |t|
t.integer "episode_id"
@@ -86,4 +86,15 @@
t.string "github_uid"
end
+ create_table "versions", :force => true 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"], :name => "index_versions_on_item_type_and_item_id"
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.