diff options
author | David Gay <david@davidgay.org> | 2021-06-13 21:40:42 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-06-13 21:40:51 -0400 |
commit | 03b8bfa53b02754d7c375690d92ed83c1cd661da (patch) | |
tree | 175a6b7b7de6355a626f464b9881f1dfa3cf3d2d /app/controllers | |
parent | 0637f55dd896a48f1dc3dd544f377b0f48017071 (diff) |
Fix wrong param name in new CharacterController `#set_character`
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/characters/skills_controller.rb | 15 | ||||
-rw-r--r-- | app/controllers/characters_controller.rb | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/app/controllers/characters/skills_controller.rb b/app/controllers/characters/skills_controller.rb new file mode 100644 index 0000000..6fcf417 --- /dev/null +++ b/app/controllers/characters/skills_controller.rb @@ -0,0 +1,15 @@ +class Characters::SkillsController < ApplicationController + before_action :set_character, only: :index + + def index + end + + private + def set_character + @character = Character.find(params[:character_id]) + unless current_char == @character + flash[:alert] = "You can only look at your own skills." + redirect_to character_path(@character) + end + end +end diff --git a/app/controllers/characters_controller.rb b/app/controllers/characters_controller.rb index 1a91988..2eb906b 100644 --- a/app/controllers/characters_controller.rb +++ b/app/controllers/characters_controller.rb @@ -37,7 +37,7 @@ class CharactersController < ApplicationController end def set_character - @character = Character.find(params[:character_id]) + @character = Character.find(params[:id]) unless current_char == @character flash[:alert] = "You can only manage your own character." redirect_to character_path(@character) |