Ehud Rosenberg wrote:
thanks for the quick response.
However, I'm not sure I got it... isn't that exactly
what flash is for? to store a message for the next
redirect and then be deleted automatically?
You're right. I just flipped to p.322 in AWDwR (v1) and it says "values stored into the flash during the processing of a request will be available during the processing of the immediately following request." My bad. I've only used flash for storing a message for rendering in the current request/response cycle and didn't remember that. So it will live through the redirect. There's also a note at the bottom of the page that emphasizes the 'following request' aspect.
If not, what's the difference between what i'm doing
and the common way of doing it?
After taking another look at your code in that light, I think the answer may lie in the fact that a) your redirect_to is occurring within application.rb, or possibly b) the redirect is within / between separate domains. I don't say this with any authority, but I would speculate that either the Rails internals involved in invoking code in application.rb or the domain switching may somehow trigger the "end of request" that causes the flash to disappear. If I had the time, I'd put together a sandbox app to dig into it. Unfortunately, I don't at the moment. If you do, I hope you'll let us know what you find out. If you don't, you might think about storing the message in a session variable before you do the redirect, and then check / access it in your main page. If it exists, you know you put it there and why. Since it's in a session variable, you don' t need to worry about finding the right message for that user. It's their session. It's their message.
PS. and thanks for correcting me. I appreciate it. Best regards.