For testing purposes I wish to ensure that no session exists. To
accomplish this I wrote:
session.delete if session
But this fails if session == nil and I suspect that it does not work as
I anticipate if session exists. In the console I see this behaviour:
$ script/console
Loading development environment (Rails 2.2.2)
app.session
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.session
from
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:429:in
`session'
from (irb):1
app.session.delete if app.session
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.session
from
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:429:in
`session'
from (irb):2
Now, I believed that nil == false and that the construct "object.method
if object" should work. Evidently I am misinformed or there is
something exceptional about session that I do not know.
How is what I desire, to remove the session if one already exists,
accomplished?
For testing purposes I wish to ensure that no session exists. To
accomplish this I wrote:
session.delete if session
But this fails if session == nil and I suspect that it does not work as
I anticipate if session exists. In the console I see this behaviour:
$ script/console
Loading development environment (Rails 2.2.2)
app.session
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.session
from
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:429:in
`session'
from (irb):1
app.session.delete if app.session
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.session
from
/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:429:in
`session'
from (irb):2
Now, I believed that nil == false and that the construct "object.method
if object" should work. Evidently I am misinformed or there is
something exceptional about session that I do not know.
How is what I desire, to remove the session if one already exists,
accomplished?