0

I know there is a lot of information available for passing variables between one controller action and another, both within the same controller and to other controllers.

But what I am trying to do, which I have been unable to find any documentation on, is temporarily store a variable in one controller action, so that it is available when another controller action(within the same controller) is called shortly after.

I tried using an instance variable but it didn't work.

I don't believe I can use flash because that is only for the very next action.

A class variable wouldn't be suitable because it would lead to conflicts if users were doing things simultaneously.

Any other ideas?

1
  • If you tell us exactly what you are trying to do it would help us give you suggestions. Commented Feb 20, 2013 at 20:22

1 Answer 1

2

You likely want to use the session for this in your controller during first pass:

session[:save_me] = "for next time"

then on the next time in there

if( session[:save_me] )
 #do cool stuff here
 session[:save_me] = nil 
end

Http is stateless so we use a session to pass information from request to request.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.