The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Weird session bug

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Daniel Berger

Posts: 1383
Nickname: djberg96
Registered: Sep, 2004

Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
Weird session bug Posted: Nov 5, 2008 8:59 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Daniel Berger.
Original Post: Weird session bug
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Daniel Berger
Latest Posts From Testing 1,2,3...

Advertisement
Yesterday I spent about an hour tracking down this bizarro bug I had seen occasionally in the logs but hadn't figured out:
TypeError (singleton can't be dumped):
    C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/session/active_record_store.rb:82:in `dump'

I was finally able to reproduce this consistently. It seemed if a new user tried to log in for the first time they would smack into this bug. But, if I created their user account in advance then all was well. I eventually came to the conclusion that it was the session handling.

Further inspection revealed the culprit. I had previously implemented a feature request that new users from a specific group be given automatic visitor access (instead of simply being denied access). So, the basic code structure looked something like this:
user = User.find(uid)

if !user and login_group == 'some_special_group'
   user = User.create(visitor)
else
   # Deny access
end

session[:user] = user

Except, it turns out that while a user object returned by User.find is compatible with the session object, one returned by User.create was not compatible with the session store, and I'd get the mysterious "Singleton can't be dumped" error.

Why? Couldn't tell you. My workaround is to run User.find again for new users and assign that user object to the session.

Read: Weird session bug

Topic: Benchmarking DB2 pureXML against 1 TB of XML data Previous Topic   Next Topic Topic: Legalize Freedom

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use