From a70494be4e1767e0cb7ff4218e7f266ece56089c Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 4 Jul 2018 14:42:21 -0400 Subject: Made pokemon embeddable --- app/controllers/pokeviewer/pokemon_controller.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/pokeviewer/pokemon_controller.rb b/app/controllers/pokeviewer/pokemon_controller.rb index f2d2187..7045807 100644 --- a/app/controllers/pokeviewer/pokemon_controller.rb +++ b/app/controllers/pokeviewer/pokemon_controller.rb @@ -2,6 +2,8 @@ require_dependency "pokeviewer/application_controller" module Pokeviewer class PokemonController < ApplicationController + before_action :load_pokemon, only: [:show, :embed] + def index pokemon = Pokemon.order("trainer_id IS NULL DESC"). order(trainer_id: :asc). @@ -66,10 +68,18 @@ module Pokeviewer end def show - @pokemon = Pokemon.includes( - :trainer, :location, - current: [:species, :item, :move_1, :move_2, :move_3, :move_4] - ).find_by_uuid! params[:id] end + + def embed + render layout: false + end + + protected + def load_pokemon + @pokemon = Pokemon.includes( + :trainer, :location, + current: [:species, :item, :move_1, :move_2, :move_3, :move_4] + ).find_by_uuid! params[:id] + end end end -- cgit 1.4.1