Sha256: 7d732c560e1eaeceb7a5d06104bcbff24625471fa6ef04bc787998bb611220bf

Contents?: true

Size: 745 Bytes

Versions: 6

Compression:

Stored size: 745 Bytes

Contents

module Worthwhile
  # Inherit from the host app's ApplicationController
  # This will configure e.g. the layout used by the host
  module ApplicationControllerBehavior
    extend ActiveSupport::Concern
    
    included do
      helper Worthwhile::MainAppHelpers
      
      rescue_from CanCan::AccessDenied do |exception|
        if [:show, :edit, :update, :destroy].include? exception.action
          render 'unauthorized', status: :unauthorized
        else
          redirect_to main_app.root_url, alert: exception.message
        end
      end

      rescue_from ActiveFedora::ObjectNotFoundError do |exception|
        render file: "#{Rails.root}/public/404", format: :html, status: :not_found, layout: false
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
worthwhile-0.1.2 app/controllers/concerns/worthwhile/application_controller_behavior.rb
worthwhile-0.1.1 app/controllers/concerns/worthwhile/application_controller_behavior.rb
worthwhile-0.1.0 app/controllers/concerns/worthwhile/application_controller_behavior.rb
worthwhile-0.0.3 app/controllers/concerns/worthwhile/application_controller_behavior.rb
worthwhile-0.0.2 app/controllers/concerns/worthwhile/application_controller_behavior.rb
worthwhile-0.0.1 app/controllers/concerns/worthwhile/application_controller_behavior.rb