Variable Scope

Scenario:

I’ve got a 4 step checkout. During the 2nd step, I collect order info
and
set to a model variable Order and store that in a session var called
session[:order] to process later or repopulate the form if they do not
finish checkout. I do NOT, however want to store the credit card number
in
the session, yet I still need to carry it over from the 2nd step to the
final step.

Question:

What’s the best way to carry the CC# over a few steps without storing it
in
the session and without creating a hidden form input. Class variables?
The
flash?

Thanks,
Chad

Hi Chad,

I think using the flash would be your best option. Just pass it from
Step2 to Step3, then to Step4. that should do it.

Cheers,
Simon

One problem:

Say they get to the review step and hit refresh a few times, or remove
a product, or… Flash goes bye bye.

Give that the flash itself is just stored in the session, what’s the
problem with storing in the flash

One other possibility (maybe overkill) is backgroundrb, you can use it
to cache objects between requests. Depending on what you’re worried
about, the fact that (unlike sessions) it will never hit the disk or
database may be an advantage.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs