Flash object not clearing?

My flash object stays persistent even after I redirect to the next page.
For example, I may set flash[:foo], then redirect to /bar, which
successfully shows the flash[:foo] field. But if I then click on
another page that also displays flash[:foo], it shows the same contents
from the prior page. The flash[:foo] field persisted past the first
page redirect. but I thought it was supposed to be erased.

Does anyone have any ideas why this may be happening?

This was recently reported on the rails-core mailing list. I’ve
cut-and-paste the email below. Maybe this is the same issue you’re

Hi all,

Recently I ran into an issue where a flash was being kept during a
redirect chain, and it ended up that one redirect happened inside a
before_filter that returned false.

I chased down the issue, and indeed the flash is not swept if the
filter chain is halted.

Going down the svn logs I found a reference to a ticket where Kaes,
among other things, revised my flash implementation. In this ticket
(3527) he suggests that flash.sweep should always run, but the ticket
is closed and there’s no further comment on the issue.

Because I ran into trouble with the ways things are currently
implemented, I’m wondering if maybe we should take Kaes suggestion
and sweep unconditionally.

The only con I can see is that, as things are now, with the sweep not
running after an aborted filter chain, it’s possible to handle the
situation manually, that is, just run flash.sweep inside your
aborting filter. So, as things are now you have more control, but you
have to remember to call it.

I believe the expected behavior is for the flash to always be swept.
So I’d give in some control for less surprise.

What do you think?