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