about summary refs log tree commit diff stats
path: root/app/models
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-01-13 17:28:31 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-01-13 17:28:31 -0500
commit173effd7a9b847d156a5548e29ae7df67798c7a2 (patch)
treea1f3181973a54051a6191c1b7067b547818d4680 /app/models
parent7e4b9ea0c23eb660ab36a6114a7a3046d8f1c5f6 (diff)
downloadpokeviewer-173effd7a9b847d156a5548e29ae7df67798c7a2.tar.gz
pokeviewer-173effd7a9b847d156a5548e29ae7df67798c7a2.tar.bz2
pokeviewer-173effd7a9b847d156a5548e29ae7df67798c7a2.zip
Fixed incorrect icon eager loading bug on front page
A bug was causing a Vigoroth which had evolved into a Slaking to still show up as a Vigoroth on the front page of the engine, even though it showed up properly on its show page. This was deemed to be caused by eager loading.
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)