You should store the value in session
.
Using a class variable will give you some troubles, i.e. when there is more than one user, when the user connects to different workers on subsequent requests, when you restart your server between the requests.
You can read more about session storage here: http://guides.rubyonrails.org/action_controller_overview.html#session