class PlayersController < ApplicationController before_action :set_player, only: [:show, :edit, :update, :destroy] respond_to :html, :json def index @players = Player.all respond_with(@players) 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 def new @player = Player.new respond_with(@player) end def edit end def create @player = Player.new(player_params) @player.save respond_with(@player) end def update @player.update(player_params) respond_with(@player) end def destroy @player.destroy respond_with(@player) end private def set_player @player = Player.find(params[:id]) end def player_params params.require(:player).permit(:game_id, :user_id) end end