偶尔中断更改会导致 ActionDispatch::Session::SessionRestoreError 异常。能够做这样的事情来自动清除无效会话会很棒:
class ApplicationController < ActionController::Base
rescue_from ActionDispatch::Session::SessionRestoreError do |exception|
reset_session
redirect_to :home
end
end
这不起作用——我假设是因为异常发生在较低的 ActionDispatch 层。有没有办法从这些错误中恢复?