From 57a3282ffb5f3b9af0b081ca69ba150610cc36c9 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sun, 7 Apr 2013 06:08:34 -0400 Subject: [PATCH] Catch cancan exception in application_controller --- app/controllers/application_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e8065d9..d26dda4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,8 @@ class ApplicationController < ActionController::Base protect_from_forgery + + rescue_from CanCan::AccessDenied do |exception| + flash[:error] = "Access denied." + redirect_to root_url + end end