Anyone knows how to preserve the value from the previous action controller?
- I have 2 controllers: foo_one and foo_two.
- on action foo_one, I have variable @my_value
- How I can keep the value of @my_value so I can use it on the second controller foo_two
@my_value = params[:preserve_value]
I don’t want to use session or global variable. any suggestion?
Assuming foo_one calls foo_too (so it’s in the same request - hence your global variable mention), then you could define an attr_accessor on foo_two’s controller and set it from there.
But, if it’s not being executed in the same request, session (be it Rails session, database or memcached) is the only way (or flash so it’s automatically removed after the next request).
Thanks for your reply.
I will do research on memcached