summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/games/ptu/pokemon_controller.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/controllers/games/ptu/pokemon_controller.rb b/app/controllers/games/ptu/pokemon_controller.rb
index 8290a73..485f03d 100644
--- a/app/controllers/games/ptu/pokemon_controller.rb
+++ b/app/controllers/games/ptu/pokemon_controller.rb
@@ -1,4 +1,26 @@
class Games::Ptu::PokemonController < ApplicationController
def show
+ @pokemon = PtuPokemon.find(params[:id])
end
+
+ def new
+ @pokemon = PtuPokemon.new
+ end
+
+ def create
+ @pokemon = PtuPokemon.new(pokemon_params)
+ if @pokemon.save
+ flash[:success] = "Created Pokémon #{@pokemon.name}."
+ redirect_to games_ptu_pokemon_path(@pokemon)
+ else
+ flash[:error] = "Failed to create Pokémon."
+ redirect_to new_games_ptu_pokemon_path
+ end
+ end
+
+ private
+ def pokemon_params
+ params.require(:ptu_pokemon).permit(:name, :base_hp, :base_atk, :base_def, :base_spatk, :base_spdef,
+ :base_speed, :male_chance, :notes)
+ end
end