2
在我的rails 3应用程序中,我使用的是devise 3.2.4和cancancan 1.9.2。我的问题是关于可超时设计模块,它工作正常,但我无法拯救正确的异常,以便我可以向用户显示正确的通知。cancancan + devise:处理可超时异常
我application_controller.rb包含:
rescue_from Exception do |exception|
unless Rails.env.production?
raise exception
else
redirect_to :back, :flash => { :error => exception.message }
end
end
# https://github.com/ryanb/cancan/wiki/exception-handling
rescue_from CanCan::AccessDenied do |exception|
flash[:error] = exception.message
respond_to do |wants|
wants.html { redirect_to main_app.root_url }
wants.js { render :file => "shared/update_flash_messages" }
end
end
每当会话过期我可以拯救通用CanCan::AccessDenied
异常与消息您无权访问此页但我想赶上可超时设计(我猜)例外,以便我可以显示默认设计消息:您的会话已过期。请重新登录以继续
任何想法?
我有完全相同的问题... – 2014-11-26 23:19:55