about summary refs log tree commit diff stats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/pokeviewer/pokemon.rb5
-rw-r--r--app/models/pokeviewer/trainer.rb4
2 files changed, 3 insertions, 6 deletions
diff --git a/app/models/pokeviewer/pokemon.rb b/app/models/pokeviewer/pokemon.rb index db3da5a..012abab 100644 --- a/app/models/pokeviewer/pokemon.rb +++ b/app/models/pokeviewer/pokemon.rb
@@ -4,6 +4,7 @@ module Pokeviewer
4 extend ActiveModel::Naming 4 extend ActiveModel::Naming
5 5
6 has_many :revisions, -> { order "sequential_id ASC" }, dependent: :destroy 6 has_many :revisions, -> { order "sequential_id ASC" }, dependent: :destroy
7 has_one :current, -> { order "sequential_id DESC" }, class_name: "Revision"
7 8
8 belongs_to :trainer, optional: true 9 belongs_to :trainer, optional: true
9 10
@@ -76,10 +77,6 @@ module Pokeviewer
76 uuid 77 uuid
77 end 78 end
78 79
79 def current
80 revisions.last
81 end
82
83 def outsider? 80 def outsider?
84 (trainer.nil?) or (ot_name != trainer.name) or (ot_number != trainer.number) 81 (trainer.nil?) or (ot_name != trainer.name) or (ot_number != trainer.number)
85 end 82 end
diff --git a/app/models/pokeviewer/trainer.rb b/app/models/pokeviewer/trainer.rb index 281e0aa..0ea12c8 100644 --- a/app/models/pokeviewer/trainer.rb +++ b/app/models/pokeviewer/trainer.rb
@@ -39,11 +39,11 @@ module Pokeviewer
39 validates :box_14_name, presence: true 39 validates :box_14_name, presence: true
40 40
41 def party 41 def party
42 pokemon.party.includes(revisions: [:species]) 42 pokemon.party.includes(current: [:species])
43 end 43 end
44 44
45 def box(n) 45 def box(n)
46 pokemon.box(n).includes(revisions: [:species]) 46 pokemon.box(n).includes(current: [:species])
47 end 47 end
48 48
49 def box_name(n) 49 def box_name(n)