2

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

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

4

1 回答 1

10

使用 Rails 4:

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

   # ...
end

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

于 2015-03-09T13:35:40.490 回答