diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/pokeviewer/pokemon_controller.rb | 18 |
1 files changed, 14 insertions, 4 deletions
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" | |||
2 | 2 | ||
3 | module Pokeviewer | 3 | module Pokeviewer |
4 | class PokemonController < ApplicationController | 4 | class PokemonController < ApplicationController |
5 | before_action :load_pokemon, only: [:show, :embed] | ||
6 | |||
5 | def index | 7 | def index |
6 | pokemon = Pokemon.order("trainer_id IS NULL DESC"). | 8 | pokemon = Pokemon.order("trainer_id IS NULL DESC"). |
7 | order(trainer_id: :asc). | 9 | order(trainer_id: :asc). |
@@ -66,10 +68,18 @@ module Pokeviewer | |||
66 | end | 68 | end |
67 | 69 | ||
68 | def show | 70 | def show |
69 | @pokemon = Pokemon.includes( | ||
70 | :trainer, :location, | ||
71 | current: [:species, :item, :move_1, :move_2, :move_3, :move_4] | ||
72 | ).find_by_uuid! params[:id] | ||
73 | end | 71 | end |
72 | |||
73 | def embed | ||
74 | render layout: false | ||
75 | end | ||
76 | |||
77 | protected | ||
78 | def load_pokemon | ||
79 | @pokemon = Pokemon.includes( | ||
80 | :trainer, :location, | ||
81 | current: [:species, :item, :move_1, :move_2, :move_3, :move_4] | ||
82 | ).find_by_uuid! params[:id] | ||
83 | end | ||
74 | end | 84 | end |
75 | end | 85 | end |