I'm using r4rmusic (from "Ruby for Rails") as the basis for a
hangman game, but I appear to have broken something. For
some reason, @session is not retaining values for me.
At the end of the login method (user_controller.rb), I'm
setting values into @session, then redirecting, as:
puts ">>>>> redirecting" # TRACE
@session['foozle'] = 'bar'
if (@session['foozle'])
puts ">>>>> login: foozle = '#{@session['foozle']}'"
else
puts ">>>>> login: foozle is undefined"
end
You don't say what version of Rails you're using, but if it's recent, the problem could be that '@session' is no longer a supported way of referencing the session hash. Use ':session' instead. The '@' prefix denotes an instance variable. Moving to :session reduces confusion.
@session and the other instance variables are deprecated but still supported. You’ll see warnings galore until you update your code, but no breakage. Use the session method (:session is a symbol, not a method call) rather than the @session instance variable.
You don't say what version of Rails you're using, but if it's recent, the
problem could be that '@session' is no longer a supported way of
referencing
the session hash. Use ':session' instead. The '@' prefix denotes an
instance variable. Moving to :session reduces confusion.
@session and the other instance variables are deprecated but still
supported. You'll see warnings galore until you update your code, but no
breakage.
And sometimes after you update your code
$ for f in `find app -type f -not -path "*svn*"`;
do grep "@flash" $a; done
$ cd test/integration
$ ruby user_changes_profile_test.rb
Loaded suite user_changes_profile_test
Started
DEPRECATION WARNING: @flash is deprecated! Call flash. instead of
@flash..
# etc.
This is on edge (r. 5271). I haven't dug into where it's coming from
yet.