# Re: flash message not shown after redirect\_to

**URL:** <https://www.ruby-forum.com/t/re-flash-message-not-shown-after-redirect-to/91128>\
**Category:** Rails\
**Created:** [April 4, 2007, 11:24pm UTC](https://www.ruby-forum.com/t/re-flash-message-not-shown-after-redirect-to/91128 "2007-04-04T23:24:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![blakeage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@blakeage](https://www.ruby-forum.com/u/blakeage)\
**Post date:** [April 4, 2007, 11:24pm UTC](https://www.ruby-forum.com/t/re-flash-message-not-shown-after-redirect-to/91128/1 "2007-04-04T23:24:15Z")

</div>

Ehud,

I think I know what’s going on here.

Think of redirect\_to like a render() call that just sends a response  
which  
causes the browser to request the page you passed to redirect\_to.

There are 3 request/response cycles involved here. You are putting  
something  
in the flash in one action which then renders a page (cycle 1), then the  
user clicks a link on that page to an action which redirects (cycle 2).  
That  
causes the browser to request, and the server to deliver, another page  
(cycle 3). The values you put in the flash during cycle 1 will be intact  
during cycle 2 but they’re gone in cycle 3.

Is this what’s goin’ down?

Solution: flash.keep()  
In cycle 2, before calling redirect\_to, call flash.keep . . you can pass  
it  
a key from the hash if you only want to preserve part of the flash hash.

🕶

---

<div class="post-metadata">

**Author:** ![blakeage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@blakeage](https://www.ruby-forum.com/u/blakeage)\
**Post date:** [April 5, 2007, 1:16am UTC](https://www.ruby-forum.com/t/re-flash-message-not-shown-after-redirect-to/91128/2 "2007-04-05T01:16:25Z")

</div>

Cool. I hadn’t come across flash.keep. Thanks, Blake.

Best regards,  
Bill
