about summary refs log tree commit diff stats
path: root/app/controllers
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-07-04 14:42:21 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-07-04 14:42:21 -0400
commita70494be4e1767e0cb7ff4218e7f266ece56089c (patch)
tree9e9c93272e8ed4d55091ba4a61f2787e1229a958 /app/controllers
parent006cf8cebfb4e2d2dcfc537b6d3ccaaa14e28cfc (diff)
downloadpokeviewer-a70494be4e1767e0cb7ff4218e7f266ece56089c.tar.gz
pokeviewer-a70494be4e1767e0cb7ff4218e7f266ece56089c.tar.bz2
pokeviewer-a70494be4e1767e0cb7ff4218e7f266ece56089c.zip
Made pokemon embeddable
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/pokeviewer/pokemon_controller.rb18
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
3module Pokeviewer 3module 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
75end 85end