John
John

Reputation: 587

Rails: delete a flash message inside a custom error controller

I have a custom error controller to show dynamic error pages (for 404, 422,500, etc), everything works fine but I cannot delete a flash message (according to http://blog.plataformatec.com.br/2012/01/my-five-favorite-hidden-features-in-rails-3-2/).

Is there a way to delete the flash inside my custom error controller?

Upvotes: 2

Views: 7764

Answers (1)

Rodrigo
Rodrigo

Reputation: 4802

Using Rails 4:

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

   # ...
end

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

Upvotes: 11

Related Questions