summaryrefslogtreecommitdiff
path: root/app/controllers/characters
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/characters')
-rw-r--r--app/controllers/characters/items_controller.rb12
-rw-r--r--app/controllers/characters/rankings_controller.rb2
-rw-r--r--app/controllers/characters/skills_controller.rb15
3 files changed, 27 insertions, 2 deletions
diff --git a/app/controllers/characters/items_controller.rb b/app/controllers/characters/items_controller.rb
index 470e21c..e38b69a 100644
--- a/app/controllers/characters/items_controller.rb
+++ b/app/controllers/characters/items_controller.rb
@@ -1,6 +1,7 @@
class Characters::ItemsController < ApplicationController
+ before_action :set_character, only: :index
+
def index
- @character = Character.find(params[:character_id])
end
def equip
@@ -66,4 +67,13 @@ class Characters::ItemsController < ApplicationController
redirect_to character_items_path(current_char)
end
end
+
+ private
+ def set_character
+ @character = Character.find(params[:character_id])
+ unless current_char == @character
+ flash[:alert] = "You can only look at your own items."
+ redirect_to character_path(@character)
+ end
+ end
end
diff --git a/app/controllers/characters/rankings_controller.rb b/app/controllers/characters/rankings_controller.rb
index bbae9fc..429b487 100644
--- a/app/controllers/characters/rankings_controller.rb
+++ b/app/controllers/characters/rankings_controller.rb
@@ -6,4 +6,4 @@ class Characters::RankingsController < ApplicationController
def index
@character = Character.find(params[:character_id])
end
-end \ No newline at end of file
+end
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