1
0
Fork 0

Install paper_trail and track all models

This commit is contained in:
Andrew Tomaka 2015-10-09 16:45:53 -04:00
parent a438b48726
commit f7adce658e
14 changed files with 58 additions and 1 deletions

View file

@ -16,6 +16,7 @@ gem 'simple_form'
gem 'omniauth-reddit', :git => 'git://github.com/jackdempsey/omniauth-reddit.git'
gem 'active_model_serializers'
gem 'paper_trail'
# AUTHORIZATION
gem 'pundit'

View file

@ -118,6 +118,10 @@ GEM
omniauth-oauth2 (1.3.1)
oauth2 (~> 1.0)
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)
puma (2.14.0)
pundit (1.0.1)
@ -163,6 +167,7 @@ GEM
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
request_store (1.2.0)
rolify (4.1.1)
ruby-graphviz (1.2.2)
sass (3.4.18)
@ -225,6 +230,7 @@ DEPENDENCIES
jbuilder (~> 2.0)
jquery-rails
omniauth-reddit!
paper_trail
pg
puma
pundit

View file

@ -1,3 +1,5 @@
class AwakenType < ActiveRecord::Base
has_paper_trail
validates :name, presence: true
end

View file

@ -1,4 +1,6 @@
class Card < ActiveRecord::Base
has_paper_trail
belongs_to :character
belongs_to :rarity
belongs_to :type

View file

@ -1,4 +1,6 @@
class Character < ActiveRecord::Base
has_paper_trail
validates :name, presence: true,
uniqueness: { case_sensitive: false }

View file

@ -1,3 +1,5 @@
class LeaderSkill < ActiveRecord::Base
has_paper_trail
validates :description, presence: true
end

View file

@ -1,4 +1,6 @@
class Link < ActiveRecord::Base
has_paper_trail
has_and_belongs_to_many :cards
validates :name, presence: true,

View file

@ -1,4 +1,6 @@
class PassiveSkill < ActiveRecord::Base
has_paper_trail
validates :name, presence: true
validates :description, presence: true

View file

@ -1,4 +1,6 @@
class Rarity < ActiveRecord::Base
has_paper_trail
validates :name, presence: true,
uniqueness: { case_sensitive: false }
validates :description, presence: true

View file

@ -1,4 +1,6 @@
class SuperAttack < ActiveRecord::Base
has_paper_trail
validates :name, presence: true
validates :description, presence: true

View file

@ -1,4 +1,6 @@
class Type < ActiveRecord::Base
has_paper_trail
validates :name, presence: true,
uniqueness: { case_sensitive: false }
validates :description, presence: true

View file

@ -1,4 +1,5 @@
class User < ActiveRecord::Base
has_paper_trail
rolify
after_create :set_admin, if: :first_user?

View 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

View file

@ -11,7 +11,7 @@
#
# 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|
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"
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