Created
June 19, 2011 13:31
Revisions
-
tanraya created this gist
Jun 19, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ # coding: utf-8 class ApplicationController < ActionController::Base protect_from_forgery rescue_from Exception, :with => :handle_exceptions private def handle_exceptions(e) case e when CanCan::AccessDenied authenticate_user! when ActiveRecord::RecordNotFound not_found else internal_error(e) end end def not_found # Just render view render 'application/not_found', :status => 404 end def internal_error(exception) if RAILS_ENV == 'production' # Send message to admin email via exception_notification request.env['exception_notifier.options'] = { :sender_address => "[email protected]", :exception_recipients => "[email protected]" } ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver # And just render view render :layout => 'layouts/internal_error', :template => 'application/internal_error', :status => 500 else throw exception end end end