Install paper_trail and track all models
This commit is contained in:
parent
a438b48726
commit
f7adce658e
14 changed files with 58 additions and 1 deletions
1
Gemfile
1
Gemfile
|
@ -16,6 +16,7 @@ gem 'simple_form'
|
||||||
gem 'omniauth-reddit', :git => 'git://github.com/jackdempsey/omniauth-reddit.git'
|
gem 'omniauth-reddit', :git => 'git://github.com/jackdempsey/omniauth-reddit.git'
|
||||||
|
|
||||||
gem 'active_model_serializers'
|
gem 'active_model_serializers'
|
||||||
|
gem 'paper_trail'
|
||||||
|
|
||||||
# AUTHORIZATION
|
# AUTHORIZATION
|
||||||
gem 'pundit'
|
gem 'pundit'
|
||||||
|
|
|
@ -118,6 +118,10 @@ GEM
|
||||||
omniauth-oauth2 (1.3.1)
|
omniauth-oauth2 (1.3.1)
|
||||||
oauth2 (~> 1.0)
|
oauth2 (~> 1.0)
|
||||||
omniauth (~> 1.2)
|
omniauth (~> 1.2)
|
||||||
|
paper_trail (4.0.0)
|
||||||
|
activerecord (>= 3.0, < 6.0)
|
||||||
|
activesupport (>= 3.0, < 6.0)
|
||||||
|
request_store (~> 1.1)
|
||||||
pg (0.18.3)
|
pg (0.18.3)
|
||||||
puma (2.14.0)
|
puma (2.14.0)
|
||||||
pundit (1.0.1)
|
pundit (1.0.1)
|
||||||
|
@ -163,6 +167,7 @@ GEM
|
||||||
thor (>= 0.18.1, < 2.0)
|
thor (>= 0.18.1, < 2.0)
|
||||||
rake (10.4.2)
|
rake (10.4.2)
|
||||||
rdoc (4.2.0)
|
rdoc (4.2.0)
|
||||||
|
request_store (1.2.0)
|
||||||
rolify (4.1.1)
|
rolify (4.1.1)
|
||||||
ruby-graphviz (1.2.2)
|
ruby-graphviz (1.2.2)
|
||||||
sass (3.4.18)
|
sass (3.4.18)
|
||||||
|
@ -225,6 +230,7 @@ DEPENDENCIES
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
omniauth-reddit!
|
omniauth-reddit!
|
||||||
|
paper_trail
|
||||||
pg
|
pg
|
||||||
puma
|
puma
|
||||||
pundit
|
pundit
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
class AwakenType < ActiveRecord::Base
|
class AwakenType < ActiveRecord::Base
|
||||||
|
has_paper_trail
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class Card < ActiveRecord::Base
|
class Card < ActiveRecord::Base
|
||||||
|
has_paper_trail
|
||||||
|
|
||||||
belongs_to :character
|
belongs_to :character
|
||||||
belongs_to :rarity
|
belongs_to :rarity
|
||||||
belongs_to :type
|
belongs_to :type
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class Character < ActiveRecord::Base
|
class Character < ActiveRecord::Base
|
||||||
|
has_paper_trail
|
||||||
|
|
||||||
validates :name, presence: true,
|
validates :name, presence: true,
|
||||||
uniqueness: { case_sensitive: false }
|
uniqueness: { case_sensitive: false }
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
class LeaderSkill < ActiveRecord::Base
|
class LeaderSkill < ActiveRecord::Base
|
||||||
|
has_paper_trail
|
||||||
|
|
||||||
validates :description, presence: true
|
validates :description, presence: true
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class Link < ActiveRecord::Base
|
class Link < ActiveRecord::Base
|
||||||
|
has_paper_trail
|
||||||
|
|
||||||
has_and_belongs_to_many :cards
|
has_and_belongs_to_many :cards
|
||||||
|
|
||||||
validates :name, presence: true,
|
validates :name, presence: true,
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class PassiveSkill < ActiveRecord::Base
|
class PassiveSkill < ActiveRecord::Base
|
||||||
|
has_paper_trail
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
validates :description, presence: true
|
validates :description, presence: true
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class Rarity < ActiveRecord::Base
|
class Rarity < ActiveRecord::Base
|
||||||
|
has_paper_trail
|
||||||
|
|
||||||
validates :name, presence: true,
|
validates :name, presence: true,
|
||||||
uniqueness: { case_sensitive: false }
|
uniqueness: { case_sensitive: false }
|
||||||
validates :description, presence: true
|
validates :description, presence: true
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class SuperAttack < ActiveRecord::Base
|
class SuperAttack < ActiveRecord::Base
|
||||||
|
has_paper_trail
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
validates :description, presence: true
|
validates :description, presence: true
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class Type < ActiveRecord::Base
|
class Type < ActiveRecord::Base
|
||||||
|
has_paper_trail
|
||||||
|
|
||||||
validates :name, presence: true,
|
validates :name, presence: true,
|
||||||
uniqueness: { case_sensitive: false }
|
uniqueness: { case_sensitive: false }
|
||||||
validates :description, presence: true
|
validates :description, presence: true
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class User < ActiveRecord::Base
|
class User < ActiveRecord::Base
|
||||||
|
has_paper_trail
|
||||||
rolify
|
rolify
|
||||||
|
|
||||||
after_create :set_admin, if: :first_user?
|
after_create :set_admin, if: :first_user?
|
||||||
|
|
20
db/migrate/20151009204428_create_versions.rb
Normal file
20
db/migrate/20151009204428_create_versions.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
class CreateVersions < ActiveRecord::Migration
|
||||||
|
|
||||||
|
# The largest text column available in all supported RDBMS is
|
||||||
|
# 1024^3 - 1 bytes, roughly one gibibyte. We specify a size
|
||||||
|
# so that MySQL will use `longtext` instead of `text`. Otherwise,
|
||||||
|
# when serializing very large objects, `text` might not be big enough.
|
||||||
|
TEXT_BYTES = 1_073_741_823
|
||||||
|
|
||||||
|
def change
|
||||||
|
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, :limit => TEXT_BYTES
|
||||||
|
t.datetime :created_at
|
||||||
|
end
|
||||||
|
add_index :versions, [:item_type, :item_id]
|
||||||
|
end
|
||||||
|
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20151008192100) do
|
ActiveRecord::Schema.define(version: 20151009204428) do
|
||||||
|
|
||||||
create_table "awaken_types", force: :cascade do |t|
|
create_table "awaken_types", force: :cascade do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
@ -134,4 +134,15 @@ ActiveRecord::Schema.define(version: 20151008192100) do
|
||||||
|
|
||||||
add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
|
add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
|
||||||
|
|
||||||
|
create_table "versions", force: :cascade 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", limit: 1073741823
|
||||||
|
t.datetime "created_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue