diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/pokeviewer/pokemon.rb | 2 | ||||
-rw-r--r-- | app/models/pokeviewer/revision.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/app/models/pokeviewer/pokemon.rb b/app/models/pokeviewer/pokemon.rb index 114e9dd..3b750ac 100644 --- a/app/models/pokeviewer/pokemon.rb +++ b/app/models/pokeviewer/pokemon.rb | |||
@@ -4,7 +4,7 @@ module Pokeviewer | |||
4 | 4 | ||
5 | belongs_to :species | 5 | belongs_to :species |
6 | belongs_to :trainer, optional: true | 6 | belongs_to :trainer, optional: true |
7 | has_many :revisions, dependent: :destroy | 7 | has_many :revisions, -> { order "sequential_id ASC" }, dependent: :destroy |
8 | 8 | ||
9 | validate :uuid_is_constant, on: :update | 9 | validate :uuid_is_constant, on: :update |
10 | before_create :set_uuid | 10 | before_create :set_uuid |
diff --git a/app/models/pokeviewer/revision.rb b/app/models/pokeviewer/revision.rb index 9d1ddf4..4cafd07 100644 --- a/app/models/pokeviewer/revision.rb +++ b/app/models/pokeviewer/revision.rb | |||
@@ -1,5 +1,15 @@ | |||
1 | require 'active_record/diff' | ||
2 | |||
1 | module Pokeviewer | 3 | module Pokeviewer |
2 | class Revision < ApplicationRecord | 4 | class Revision < ApplicationRecord |
5 | include ActiveRecord::Diff | ||
6 | |||
7 | diff :nickname, :experience, :level, :hp, :attack, :defense, | ||
8 | :special_attack, :special_defense, :speed, :coolness, :beauty, :cuteness, | ||
9 | :smartness, :toughness, :sheen, :hold_item, :move_1_id, :move_2_id, | ||
10 | :move_3_id, :move_4_id, :move_1_pp_bonuses, :move_2_pp_bonuses, | ||
11 | :move_3_pp_bonuses, :move_4_pp_bonuses | ||
12 | |||
3 | belongs_to :pokemon | 13 | belongs_to :pokemon |
4 | acts_as_sequenced scope: :pokemon_id | 14 | acts_as_sequenced scope: :pokemon_id |
5 | 15 | ||