Need help debugging a Singleton TypeError in my app.

I keep getting this error:

TypeError (singleton can't be dumped):
    /lib/sql_session_store.rb:124:in `dump'
    /lib/sql_session_store.rb:124:in `marshalize'
    /lib/sql_session_store.rb:91:in `close'
    /usr/local/lib/ruby/1.8/cgi/session.rb:330:in `close'

/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:1015:in
`close_session'

This only recently started happening and I haven't changed much of
anywhere from before I started getting this error.

This happens when I'm updating a user account (I'm using
auth_generator). Weird thing is if I take the image upload form field
out of the view, it runs fine... But I kind of need that form field to
update user icons (Again this worked fine a little while ago and I've
tried to revert any changes I've made since with no luck, obviously I
missed something. I suppose I should write better tests :-\ ). I'm
just having trouble finding out where the actual problem is.

What are the most common causes of the: "TypeError (singleton can't be
dumped)" error? Thanks.

marston@sugarstats.com wrote:

I keep getting this error:

TypeError (singleton can't be dumped):
    /lib/sql_session_store.rb:124:in `dump'
    /lib/sql_session_store.rb:124:in `marshalize'
    /lib/sql_session_store.rb:91:in `close'
    /usr/local/lib/ruby/1.8/cgi/session.rb:330:in `close'

/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:1015:in
`close_session'

This only recently started happening and I haven't changed much of
anywhere from before I started getting this error.

This happens when I'm updating a user account (I'm using
auth_generator). Weird thing is if I take the image upload form field
out of the view, it runs fine... But I kind of need that form field to
update user icons (Again this worked fine a little while ago and I've
tried to revert any changes I've made since with no luck, obviously I
missed something. I suppose I should write better tests :-\ ). I'm
just having trouble finding out where the actual problem is.

What are the most common causes of the: "TypeError (singleton can't be
dumped)" error? Thanks.

The dumping in question is the serialisation of an object into the session. In Ruby terminology, a singleton is an instance that has methods added to it (i.e. methods in addition to those defined in its class).

As a general point, your application will be more robust if you hold the IDs of persistent objects in your session, rather than the objects themselves.

I hope that helps, because that's the whole extent of my knowledge!

regards

   Justin Forder

"What are the most common causes of the: "TypeError (singleton can't be
dumped)" error? "
you put IO kind of objects or singleton obj into session, when rails
try to serialize it and save it into session, ruby complains since they
can't be marshalled/serialized.

uploaded image blob is of StringIO type, you should exclude that from
saving into session.

wuyaSea Operator
www.wuyaSea.com