From 69c927c32774c1fbca315254ef0ff2b99138c21f Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 14 Jan 2019 13:31:19 -0500 Subject: Added revision permalinks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are now URLs for each revision of a Pokémon. They are not linked to from anywhere yet. There are no embeds for them yet. refs #5 --- app/controllers/pokeviewer/pokemon_controller.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/pokeviewer/pokemon_controller.rb b/app/controllers/pokeviewer/pokemon_controller.rb index 7045807..2c38e56 100644 --- a/app/controllers/pokeviewer/pokemon_controller.rb +++ b/app/controllers/pokeviewer/pokemon_controller.rb @@ -70,6 +70,21 @@ module Pokeviewer def show end + def show_revision + @revision = Revision. + where( + sequential_id: params[:revision_id], + pokeviewer_pokemon: { uuid: params[:id] } + ).includes( + :species, :item, :move_1, :move_2, :move_3, :move_4, + pokemon: [:trainer, :location] + ).first + + @pokemon = @revision.pokemon + + render :show + end + def embed render layout: false end @@ -77,9 +92,12 @@ module Pokeviewer protected def load_pokemon @pokemon = Pokemon.includes( - :trainer, :location, - current: [:species, :item, :move_1, :move_2, :move_3, :move_4] + current: [ + :species, :item, :move_1, :move_2, :move_3, :move_4, + pokemon: [:trainer, :location]] ).find_by_uuid! params[:id] + + @revision = @pokemon.current end end end -- cgit 1.4.1