Flash for more than notices

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

Why not just use the session?

On 12/7/05, Tom D. [email protected] 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

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 :slight_smile: 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

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

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