Mild Fuzz
Mild Fuzz

Reputation: 30681

persistant instance variables in rails 3

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?

Upvotes: 1

Views: 381

Answers (1)

Carlos Ramirez III
Carlos Ramirez III

Reputation: 7434

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

Upvotes: 1

Related Questions