TypeError


#1

What might cause this error?

TypeError (singleton can’t be dumped):
/usr/lib/ruby/1.8/pstore.rb:159:in dump' /usr/lib/ruby/1.8/pstore.rb:159:indump’
/usr/lib/ruby/1.8/pstore.rb:138:in transaction' /usr/lib/ruby/1.8/cgi/session/pstore.rb:90:inupdate’
/usr/lib/ruby/1.8/cgi/session/pstore.rb:97:in close' /usr/lib/ruby/1.8/cgi/session.rb:330:inclose’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/
action_controller/base.rb:914:in close_session' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/ action_controller/base.rb:372:inprocess_without_session_management_support’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/
action_controller/session_management.rb:116:in process' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:indispatch’
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:
117:in handle_dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb: 83:inservice’
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
/usr/lib/ruby/1.8/webrick/server.rb:155:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:144:instart’
/usr/lib/ruby/1.8/webrick/server.rb:144:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:94:instart’
/usr/lib/ruby/1.8/webrick/server.rb:89:in each' /usr/lib/ruby/1.8/webrick/server.rb:89:instart’
/usr/lib/ruby/1.8/webrick/server.rb:79:in start' /usr/lib/ruby/1.8/webrick/server.rb:79:instart’
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:
69:in dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/ webrick.rb:59 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:inrequire__’
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
require' /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/ active_support/dependencies.rb:214:inrequire’
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
require__' /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:inrequire’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/
active_support/dependencies.rb:214:in `require’
./script/server:3


#2

Something in the session can’t be serialized?

b


#3

Don’t store into session objects that have singlton methods:

$ irb
irb(main):001:0> o = Object.new
=> #Object:0x356838
irb(main):002:0> def o.test; puts ‘test’ end
=> nil
irb(main):003:0> Marshal.d
Marshal.display Marshal.dup Marshal.dump
irb(main):003:0> Marshal.dump(o)
TypeError: singleton can’t be dumped
from (irb):3:in dump' from (irb):3:inbinding’
from :0
irb(main):004:0>

Kent.


#4

Wow, that’s weird… why’s that? I knew threads and resources could be
serialized, but anything with a singleton method?
Oh wait, I guess that makes sense because once you’ve added a the method
to the instance it no longer meets the class
definition. Right?

b