Rails 2.2.2
Ruby 1.8.6

ActiveRecord Session Store enabled

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

>> app.get "/"
=> 200

>> app.session
=> #<CGI::Session:0xb723ba24
@dbman=#<CGI::Session::CookieStore:0xb723b8e4 @original=nil, ...

>> app.session.delete if app.session
=> []

>> app.session
=> #<CGI::Session:0xb723ba24
@dbman=#<CGI::Session::CookieStore:0xb723b8e4 @original=nil,

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?
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to