1
0
Fork 0
dokkan-data-rails/app/controllers/rarities_controller.rb

65 lines
1 KiB
Ruby
Raw Normal View History

2015-10-06 13:55:12 -04:00
class RaritiesController < ApplicationController
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