has moved and is now available at

Flash not clearing after a request?

26 September 2007

We all know “The Flash” to be a very useful tool in almost every application we write. What does “The Flash” actually do?

The flash provides a way to pass temporary objects between actions. Anything you place in the flash will be exposed to the very next action and then cleared out.
Well, that’s all nice, but what if you notice that your flash is not cleared, and is shown in one or more subsequent requests as well?

The reason your flash is not cleared is that it will only be cleared if you render the current action, or if you redirect to another action. If you render another action or template, the flash will not be cleared out.

Solving this is quite easy, actually. You only need to know how to do it. Use the following code in combination with render to show it only for the current action:[:notice] = “Render, render! This will only show up once.”
That’s all there is to it really.