work on authorization in controllers and refine ability.rb

This commit is contained in:
Stella Rouzi 2014-07-24 22:12:43 +03:00
parent 2d3a1ef37e
commit 0684dbad19
5 changed files with 23 additions and 39 deletions

View file

@ -1,17 +1,15 @@
module Admin
class SpeakersController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :speaker, through: :conference
load_resource :event, through: :conference
respond_to :js, :html
def edit
@event = @conference.events.find(params[:event_id])
@speaker = @event.event_users.where(event_role: 'speaker').first
end
def update
@event = @conference.events.find(params[:event_id])
@speaker = @event.event_users.where(event_role: 'speaker').first
@speaker.user_id = params[:speaker][:user_id]
@speaker.save