I run a check on the address line parameters to make sure the user isn't
passing my list method a :year to search for that does not exist in the
database, which would create null pointer exceptions. I then splash a
flash message telling the user that the year doesn't exist in the
database. Then, if the user enters another year into the command line
as an argument for the action, list, a year that does exist in the
database, the flash message is still displayed on this next render of
list. It is not until the second correct page is shown that the flash
message goes away. How do I fix this?
Do you, by any chance, set the flash and then redirect from a before filter?
That initial request isn't counted, a bug imo -- think that was the
consensus when this was brought up on rails-core as well, so the flash
thinks it's jsut been set when serving the next request, and that it's
supposed to stay for 1 more page.
Been a few months since I looked into this, the above may not be
correct any more.
The workaround would be to use flash.now, yes.