From 86d5bc85f2156e826734e491556a00e9acfbb96a Mon Sep 17 00:00:00 2001 From: "Jesse C. Fisher" Date: Sat, 26 Sep 2015 16:31:37 -0700 Subject: [PATCH] Show player inventory --- app/controllers/players_controller.rb | 5 ++++- app/views/players/show.html.haml | 4 ++++ app/views/players/show.json.jbuilder | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/players_controller.rb b/app/controllers/players_controller.rb index 76fe5a5..a56f817 100644 --- a/app/controllers/players_controller.rb +++ b/app/controllers/players_controller.rb @@ -1,7 +1,7 @@ class PlayersController < ApplicationController before_action :set_player, only: [:show, :edit, :update, :destroy] - respond_to :html + respond_to :html, :json def index @players = Player.all @@ -9,6 +9,9 @@ class PlayersController < ApplicationController end def show + #TODO: Authorize + # e.g. retrieve own inventory but only inventory.count of other players + # and only other players in games to which you have access respond_with(@player) end diff --git a/app/views/players/show.html.haml b/app/views/players/show.html.haml index 80707d9..f01d7db 100644 --- a/app/views/players/show.html.haml +++ b/app/views/players/show.html.haml @@ -7,6 +7,10 @@ %b User: = @player.user +%p + %b Inventory: + = @player.inventory.map{|c| c.class} + = link_to 'Edit', edit_player_path(@player) \| = link_to 'Back', players_path diff --git a/app/views/players/show.json.jbuilder b/app/views/players/show.json.jbuilder index 6c93eff..74fc67e 100644 --- a/app/views/players/show.json.jbuilder +++ b/app/views/players/show.json.jbuilder @@ -1 +1 @@ -json.extract! @player, :id, :game_id, :user_id, :created_at, :updated_at +json.extract! @player, :id, :game_id, :user_id, :inventory, :created_at, :updated_at