0

I'm setting up a simple RoR application. It mixes ActiveAdmin with CanCan to manage authorizations. When I raise a CanCan::AccessDenied, the exception is never rescured as it should:

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  protect_from_forgery
  # Ensure authorization happens on every action in your application
  check_authorization

  # If the user authorization fails, a CanCan::AccessDenied exception will be raised
  rescue_from CanCan::AccessDenied do |exception|
    redirect_to root_url, :alert => exception.message
  end

  def access_denied!(exception)
    raise CanCan::AccessDenied.new exception.message
  end
end

Instead of redirecting to the root_url, the Exception is displayed like it is not catched.

enter image description here

Any clue? Thanks!

Pirhoo
  • 680
  • 8
  • 21

0 Answers0