Class: Effective::ClassifiedsController

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

Instance Method Summary collapse

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/effective/classifieds_controller.rb', line 7

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

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

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

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

  @page_title ||= @classified.to_s
end