Ruby on Rails
Friday, September 5, 2014
What you want to achieve is possible, but you are thinking about it the wrong way. Do not call it a "global variable" --- that is not only the wrong word but refers to some other concept in Ruby which will not do what you think it will do.
Here's a great introduction to sessions & cookies with a detailed beginner explanation:
when you're in a controller and you refer to session[:xyz] (see article above) that is not a local variable, but in fact a special construct by Rails to share information across web requests from the same user. It's already implemented for you -- use it, don't re-invent the wheel.
-Jason
On Sep 4, 2014, at 4:38 PM, António <ajdacr@gmail.com> wrote:
The second controller checks the variable for knowing whether a user is logged in. The idea is the @session variable to be a "global variable" of the application, that is, used by several controllers. According to your answer, it is not possible. Is that true?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment