问题 I am using rails 5, rails_admin, devise and cancancan. Everything works correctly, but when there is access denied, it shows a 'You are not authorized to access this page' error screen. I want to redirect to root_path, I've been searching and I only found that I have to write in app/controllers/application_controller.rb this code: class ApplicationController < ActionController::Base rescue_from CanCan::AccessDenied do |exception| redirect_to root_path, :alert => exception.message end end And