2015-10-09 08:17:29 -04:00
|
|
|
class Admin::RaritiesController < Admin::BaseController
|
2015-10-06 13:55:12 -04:00
|
|
|
before_action :set_rarity, only: [:show, :edit, :update, :destroy]
|
2015-10-08 15:18:21 -04:00
|
|
|
after_action :verify_authorized
|
2015-10-06 13:55:12 -04:00
|
|
|
|
|
|
|
def index
|
|
|
|
@rarities = Rarity.all
|
2015-10-08 15:18:21 -04:00
|
|
|
|
|
|
|
authorize Rarity
|
2015-10-06 13:55:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2015-10-08 15:18:21 -04:00
|
|
|
authorize @rarity
|
2015-10-06 13:55:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@rarity = Rarity.new
|
2015-10-08 15:18:21 -04:00
|
|
|
|
|
|
|
authorize @rarity
|
2015-10-06 13:55:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@rarity = Rarity.new(rarity_params)
|
|
|
|
|
2015-10-08 15:18:21 -04:00
|
|
|
authorize @rarity
|
|
|
|
|
2015-10-06 13:55:12 -04:00
|
|
|
if @rarity.save
|
|
|
|
redirect_to rarities_path, notice: 'Rarity was created'
|
|
|
|
else
|
|
|
|
render :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2015-10-08 15:18:21 -04:00
|
|
|
authorize @rarity
|
2015-10-06 13:55:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2015-10-08 15:18:21 -04:00
|
|
|
authorize @rarity
|
|
|
|
|
2015-10-06 13:55:12 -04:00
|
|
|
if @rarity.update(rarity_params)
|
|
|
|
redirect_to rarities_path, notice: 'Rarity was updated'
|
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2015-10-08 15:18:21 -04:00
|
|
|
authorize @rarity
|
|
|
|
|
2015-10-06 13:55:12 -04:00
|
|
|
@rarity.destroy
|
|
|
|
|
|
|
|
redirect_to rarities_path, notice: 'Rarity was deleted'
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def rarity_params
|
|
|
|
params.require(:rarity).permit(:name, :description)
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_rarity
|
|
|
|
@rarity = Rarity.find(params[:id])
|
|
|
|
end
|
|
|
|
end
|