Rails:删除自定义错误控制器中的Flash消息

Joh*_*ohn 1 message ruby-on-rails exception flash-message

我有一个自定义错误控制器来显示动态错误页面(404,422,500等),一切正常但我无法删除flash消息(根据http://blog.plataformatec.com.br/2012/01/my -five-favorite-hidden-features-in-rails-3-2 /).

有没有办法删除我的自定义错误控制器中的闪存?

Rod*_*igo 9

使用Rails 4:

class ErrorController < ActionController::Base
   before_action { flash.clear }

   # ...
end
Run Code Online (Sandbox Code Playgroud)

参考:http://api.rubyonrails.org/classes/ActionDispatch/Flash/FlashHash.html#method-i-clear