For flash, first distinguish between rendering and redirect_to, because the flash message is only deleted after redirection. You are fine.
Then, if you want the message to appear in the next request after redirecting, use flash []. If you want the message to appear in the current request, use flash.now [].
See if that helps.
If you are really stuck, you can clear it in the view - although you are loading technical debt with such workarounds - but if the clock is ticking correctly Now:
- flash.slice(:notice, :message, :error, :success, :warning, :failure).each do |level, value| - if value.present? %div{:class => "flash #{h level}"} = h value - flash[level] = nil
source share