1

I am trying to hold on to the information from a form after the user has been redirected to another controller and back again.

Essentially, I need to gather some data and in cases where the user is not already signed in, redirect to the sign in then back again so the data in the first instance can be saved with their user ID

I do not want to insist the user signs in first as I think that is a usability issue in this instance.

What is a good way to do this?

1 Answer 1

1

You can use the session to store information across requests.

# to set
session[:foo] = "bar"

# to retrieve in another request
foo_var = session[:foo]

You can read about the session and best practices for using it here: http://guides.rubyonrails.org/security.html#sessions

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.