Implement role authorization

This commit is contained in:
Stella Rouzi 2014-08-12 11:51:59 +03:00
parent 6755328c4c
commit e2fb434dc7
122 changed files with 1386 additions and 751 deletions

View file

@ -1,10 +1,11 @@
class CommercialsController < ApplicationController
before_action :set_conference
load_and_authorize_resource :conference, find_by: :short_title
before_action :set_event
before_action :set_commercial, only: [:edit, :update, :destroy]
load_and_authorize_resource through: @event, except: [:new, :create]
def new
@commercial = @event.commercials.build
authorize! :new, @commercial
end
def edit
@ -12,6 +13,7 @@ class CommercialsController < ApplicationController
def create
@commercial = @event.commercials.build(commercial_params)
authorize! :create, @commercial
if @commercial.save
redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id),
@ -40,14 +42,6 @@ class CommercialsController < ApplicationController
private
def set_commercial
@commercial = @event.commercials.find(params[:id])
end
def set_conference
@conference = Conference.find_by(short_title: params[:conference_id])
end
def set_event
@event = @conference.events.find(params[:proposal_id])
end