Forum: Ruby on Rails Flash for more than notices

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
atomgiant (Guest)
on 2005-12-07 14:59
(Received via mailing list)
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
dez (Guest)
on 2005-12-07 15:32
(Received via mailing list)
Why not just use the session?
technoweenie (Guest)
on 2005-12-07 15:48
(Received via mailing list)
On 12/7/05, Tom D. <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
atomgiant (Guest)
on 2005-12-07 16:29
(Received via mailing list)
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
justin (Guest)
on 2005-12-08 00:53
(Received via mailing list)
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
atomgiant (Guest)
on 2005-12-08 03:52
(Received via mailing list)
Thanks Justin.  After typing that I thought that may be the case... I
just didn't look underneath the covers :)
This topic is locked and can not be replied to.