Exception: Acl9::AccessDenied

Inherits:
StandardError
  • Object
show all
Defined in:
lib/acl9/controller_extensions/generators.rb

Overview

This exception is raised whenever ACL block finds that the current user is not authorized for the controller action he wants to execute.

Examples:

How to catch this exception in ApplicationController

class ApplicationController < ActionController::Base
  rescue_from 'Acl9::AccessDenied', :with => :access_denied

  # ...other stuff...
  private

  def access_denied
    if current_user
      # It's presumed you have a template with words of pity and regret
      # for unhappy user who is not authorized to do what he wanted
      render :template => 'home/access_denied'
    else
      # In this case user has not even logged in. Might be OK after login.
      flash[:notice] = 'Access denied. Try to log in first.'
      redirect_to 
    end
  end
end