diff options
author | David Gay <david@davidgay.org> | 2021-04-06 21:56:44 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-04-06 21:56:44 -0400 |
commit | 4ed2a36d48b6677d7ddb137e073a985d6391b8b4 (patch) | |
tree | 5e94cc8de10e747f3157142a6fab73e99b047dcf /app/controllers/games/ptu/pokemon_controller.rb | |
parent | b85c671ca482e9d36bd2ee94231f365e7e0d65a5 (diff) |
Super-bare-bones pokemon adding and viewing
Diffstat (limited to 'app/controllers/games/ptu/pokemon_controller.rb')
-rw-r--r-- | app/controllers/games/ptu/pokemon_controller.rb | 22 |
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 |