Skip to content

subject and action not available #366

fedegl opened this Issue May 12, 2011 · 2 comments

2 participants

fedegl commented May 12, 2011

I have a orders controller and Iam authorizing with

load_and_authorize_resource :through => :current_account

When AccessDenied is raised the subject and action methods on the exception object are nil

  rescue_from CanCan::AccessDenied do |exception|
    Rails.logger.debug { "Exception: #{exception.inspect}, #{exception.subject.inspect}, #{exception.action.inspect}" }

    if exception.subject == Order
      redirect_to cart_items_path(:sign_in => true)
      redirect_to root_url, :alert => exception.message

This is the output in the Rails log

Exception: #<CanCan::AccessDenied: You are not authorized to access this page.>, nil, nil
ryanb commented May 12, 2011

Looks like this is happening on this line. I'll update this so it adds the subject/action. Thanks for reporting.

fedegl commented May 12, 2011

No worries and thank you for the great gem and quick response!

@ryanb ryanb closed this in 843fe89 May 18, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.