# Flash for more than notices

**URL:** <https://www.ruby-forum.com/t/flash-for-more-than-notices/49669>\
**Category:** Rails\
**Created:** [December 7, 2005, 1:59pm UTC](https://www.ruby-forum.com/t/flash-for-more-than-notices/49669 "2005-12-07T13:59:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![atomgiant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d26b3c/32.png) [@atomgiant](https://www.ruby-forum.com/u/atomgiant)\
**Post date:** [December 7, 2005, 1:59pm UTC](https://www.ruby-forum.com/t/flash-for-more-than-notices/49669/1 "2005-12-07T13:59:24Z")

</div>

Hi,

I am considering using the flash to store intermediate data between  
requests that is more than just a status type message.

For instance, if a user searches for some items, I will render the  
items to them keyed with the item.id and store the items in a  
flash[:items] for subsequent interactions with them (I don’t plan on  
keeping more than a dozen of these per user at a time). This will  
allow me to just have the item.id sent between requests to manipulate  
the items. In addition, in my particular case, there is no easy way  
to re-build an item from just its id (I am pulling them from an  
external source).

Does this sound like a reasonable approach?

Any feedback is appreciated.

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![atomgiant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d26b3c/32.png) [@atomgiant](https://www.ruby-forum.com/u/atomgiant)\
**Post date:** [December 7, 2005, 2:32pm UTC](https://www.ruby-forum.com/t/flash-for-more-than-notices/49669/2 "2005-12-07T14:32:00Z")

</div>

Why not just use the session?

---

<div class="post-metadata">

**Author:** ![atomgiant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d26b3c/32.png) [@atomgiant](https://www.ruby-forum.com/u/atomgiant)\
**Post date:** [December 7, 2005, 2:48pm UTC](https://www.ruby-forum.com/t/flash-for-more-than-notices/49669/3 "2005-12-07T14:48:18Z")

</div>

On 12/7/05, Tom D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> the items. In addition, in my particular case, there is no easy way  
> to re-build an item from just its id (I am pulling them from an  
> external source).
> 
> Does this sound like a reasonable approach?
> 
> Any feedback is appreciated.
> 
> Thanks,  
> Tom

That’s what the session is for. The only difference with the flash  
IIRC is that it’s wiped at the end of the next request.

–  
rick  
[http://techno-weenie.net](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![atomgiant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d26b3c/32.png) [@atomgiant](https://www.ruby-forum.com/u/atomgiant)\
**Post date:** [December 7, 2005, 3:29pm UTC](https://www.ruby-forum.com/t/flash-for-more-than-notices/49669/4 "2005-12-07T15:29:14Z")

</div>

The main reason I was leaning towards the flash is that this data is  
really only useful for the next request that follows presenting it.  
In AJAX, this would not be true, but I could just use flash.keep. I  
view the session as being more for long term session data.

By using the flash, I would not have to deal with stale data or clearing  
issues.

However, perhaps this is an abuse of the flash’s purpose. The session  
approach would definitely scale better… and come to think of it, it  
is the only one that would work in a multi-server environment.

OK, I’ve convinced myself to use the session now 🙂 The stale data  
and clearing are really not big issues since this dataset will be so  
small and should be refreshed for each user request.

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![atomgiant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d26b3c/32.png) [@atomgiant](https://www.ruby-forum.com/u/atomgiant)\
**Post date:** [December 7, 2005, 11:53pm UTC](https://www.ruby-forum.com/t/flash-for-more-than-notices/49669/5 "2005-12-07T23:53:23Z")

</div>

Tom D. wrote:

> The main reason I was leaning towards the flash is that this data is  
> really only useful for the next request that follows presenting it.  
> In AJAX, this would not be true, but I could just use flash.keep. I  
> view the session as being more for long term session data.
> 
> By using the flash, I would not have to deal with stale data or clearing issues.
> 
> However, perhaps this is an abuse of the flash’s purpose. The session  
> approach would definitely scale better… and come to think of it, it  
> is the only one that would work in a multi-server environment.

The flash is actually held in the session, under the key ‘flash’. (If it  
didn’t use the same technology as the session, _it_ wouldn’t work in a  
multi-server environment.) So if it’s more convenient, use it!

regards

Justin

---

<div class="post-metadata">

**Author:** ![atomgiant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d26b3c/32.png) [@atomgiant](https://www.ruby-forum.com/u/atomgiant)\
**Post date:** [December 8, 2005, 2:52am UTC](https://www.ruby-forum.com/t/flash-for-more-than-notices/49669/6 "2005-12-08T02:52:20Z")

</div>

Thanks Justin. After typing that I thought that may be the case… I  
just didn’t look underneath the covers 🙂
