From 173effd7a9b847d156a5548e29ae7df67798c7a2 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 13 Jan 2018 17:28:31 -0500 Subject: 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. --- app/models/pokeviewer/pokemon.rb | 5 +---- app/models/pokeviewer/trainer.rb | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'app/models') 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 extend ActiveModel::Naming has_many :revisions, -> { order "sequential_id ASC" }, dependent: :destroy + has_one :current, -> { order "sequential_id DESC" }, class_name: "Revision" belongs_to :trainer, optional: true @@ -76,10 +77,6 @@ module Pokeviewer uuid end - def current - revisions.last - end - def outsider? (trainer.nil?) or (ot_name != trainer.name) or (ot_number != trainer.number) 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 validates :box_14_name, presence: true def party - pokemon.party.includes(revisions: [:species]) + pokemon.party.includes(current: [:species]) end def box(n) - pokemon.box(n).includes(revisions: [:species]) + pokemon.box(n).includes(current: [:species]) end def box_name(n) -- cgit 1.4.1