# Need help debugging a Singleton TypeError in my app

**URL:** <https://www.ruby-forum.com/t/need-help-debugging-a-singleton-typeerror-in-my-app/78020>\
**Category:** Rails\
**Created:** [December 2, 2006, 9:48pm UTC](https://www.ruby-forum.com/t/need-help-debugging-a-singleton-typeerror-in-my-app/78020 "2006-12-02T21:48:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 2, 2006, 9:48pm UTC](https://www.ruby-forum.com/t/need-help-debugging-a-singleton-typeerror-in-my-app/78020/1 "2006-12-02T21:48:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 2, 2006, 11:04pm UTC](https://www.ruby-forum.com/t/need-help-debugging-a-singleton-typeerror-in-my-app/78020/2 "2006-12-02T23:04:35Z")

</div>

removed\_email\_address@domain.invalid wrote:

> 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 F.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 2, 2006, 11:04pm UTC](https://www.ruby-forum.com/t/need-help-debugging-a-singleton-typeerror-in-my-app/78020/3 "2006-12-02T23:04:36Z")

</div>

"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 O.  
[www.wuyaSea.com](http://www.wuyaSea.com)
