Class: Effective::EventsController

Inherits:
ApplicationController
  • Object
show all
Includes:
CrudController
Defined in:
app/controllers/effective/events_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/effective/events_controller.rb', line 10

def show
  @event = resource_scope.find(params[:id])

  if @event.respond_to?(:roles_permit?)
    raise Effective::AccessDenied.new('Access Denied', :show, @event) unless @event.roles_permit?(current_user)
  end

  EffectiveResources.authorize!(self, :show, @event)

  if EffectiveResources.authorized?(self, :admin, :effective_events)
    flash.now[:warning] = [
      'Hi Admin!',
      ('You are viewing a hidden event.' if @event.draft?),
      'Click here to',
      ("<a href='#{effective_events.edit_admin_event_path(@event)}' class='alert-link'>edit event settings</a>.")
    ].compact.join(' ')
  end

  @page_title ||= @event.to_s
end