Remove unnecessary ability from adminAbilities

CanCanCan can load @events and @event in EventsController by itself
This commit is contained in:
AEtherC0r3 2017-08-09 12:05:11 +03:00 committed by Stella Rouzi
parent c4eec6a3de
commit a87c6e55f7
4 changed files with 4 additions and 19 deletions

View file

@ -2,9 +2,11 @@ module Admin
class ReportsController < Admin::BaseController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :program, through: :conference, singleton: true
# For some reason this doesn't work, so a workaround is used
# load_and_authorize_resource :event, through: :program
def index
@events = @program.events
@events = Event.accessible_by(current_ability).where(program: @program)
@events_commercials = Commercial.where(commercialable_type: 'Event', commercialable_id: @events.pluck(:id))
@events_missing_commercial = @events.where.not(id: @events_commercials.pluck(:commercialable_id))
@events_with_requirements = @events.where.not(description: ['', nil])