# Using flash to pass data between pages

**URL:** <https://www.ruby-forum.com/t/using-flash-to-pass-data-between-pages/116135>\
**Category:** Rails\
**Created:** [October 2, 2007, 7:42pm UTC](https://www.ruby-forum.com/t/using-flash-to-pass-data-between-pages/116135 "2007-10-02T19:42:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlwinter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecccb3/32.png) [@rlwinter](https://www.ruby-forum.com/u/rlwinter)\
**Post date:** [October 2, 2007, 7:42pm UTC](https://www.ruby-forum.com/t/using-flash-to-pass-data-between-pages/116135/1 "2007-10-02T19:42:47Z")

</div>

Hi all,

Is it considered good practice to use the flash to pass temporary data  
between pages? Items such a id’s for model objects in case I want to  
retrieve the object that was used in the previous page. Or, should I  
instead use the session for this purpose, then clear the value out of  
the session when it’s no longer needed?

It seems that using the flash works okay and I get the benefit of  
having it automatically clear when it’s no longer needed. However, I’m  
not sure if there are caveats to using the flash.

---

<div class="post-metadata">

**Author:** ![rlwinter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecccb3/32.png) [@rlwinter](https://www.ruby-forum.com/u/rlwinter)\
**Post date:** [October 2, 2007, 8:09pm UTC](https://www.ruby-forum.com/t/using-flash-to-pass-data-between-pages/116135/2 "2007-10-02T20:09:15Z")

</div>

Hi,

I think using flash for passing temporary data between pages or actions  
is  
ok, since the documentation[1] tells you so.  
However I still recommend using the standard session to carry data  
between  
different actions, since it simply seems to be the designed thing to do  
so  
while flash’s primary purpose seems to be storing notices and warnings.

And you don’t run that easily into situations where you’re losing all  
your  
precious data. 😉

Cheers,  
Markus

[1] [Peak Obsession](http://api.rubyonrails.com/classes/ActionController/Flash.html)

---

<div class="post-metadata">

**Author:** ![rlwinter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecccb3/32.png) [@rlwinter](https://www.ruby-forum.com/u/rlwinter)\
**Post date:** [October 2, 2007, 8:21pm UTC](https://www.ruby-forum.com/t/using-flash-to-pass-data-between-pages/116135/3 "2007-10-02T20:21:32Z")

</div>

The flash is just a “special” hash that is stored in the session. The  
special thing about it is it’s ability to clear itself after the next  
request. As long as you are sure this behavior won’t bite you in the  
butt, there is nothing wrong with what you want to do.

---

<div class="post-metadata">

**Author:** ![rlwinter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecccb3/32.png) [@rlwinter](https://www.ruby-forum.com/u/rlwinter)\
**Post date:** [October 2, 2007, 11:43pm UTC](https://www.ruby-forum.com/t/using-flash-to-pass-data-between-pages/116135/4 "2007-10-02T23:43:52Z")

</div>

I think now it might “bite me in the butt.” After doing some  
experimenting I realize I have some issues with backtracking when  
using flash. Probably better to just store in the session and clear  
when I no longer need it.
