Forum: Ruby on Rails TypeError

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2ff47d48fde7f8f2d1e25ab7ccc87d00?d=identicon&s=25 Peter Brown (Guest)
on 2006-02-13 18:13
(Received via mailing list)
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:in `dump'
     /usr/lib/ruby/1.8/pstore.rb:138:in `transaction'
     /usr/lib/ruby/1.8/cgi/session/pstore.rb:90:in `update'
     /usr/lib/ruby/1.8/cgi/session/pstore.rb:97:in `close'
     /usr/lib/ruby/1.8/cgi/session.rb:330:in `close'
     /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:in
`process_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:in
`dispatch'
     /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:in `service'
     /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
     /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
     /usr/lib/ruby/1.8/webrick/server.rb:155:in `start_thread'
     /usr/lib/ruby/1.8/webrick/server.rb:144:in `start'
     /usr/lib/ruby/1.8/webrick/server.rb:144:in `start_thread'
     /usr/lib/ruby/1.8/webrick/server.rb:94:in `start'
     /usr/lib/ruby/1.8/webrick/server.rb:89:in `each'
     /usr/lib/ruby/1.8/webrick/server.rb:89:in `start'
     /usr/lib/ruby/1.8/webrick/server.rb:79:in `start'
     /usr/lib/ruby/1.8/webrick/server.rb:79:in `start'
     /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:in
`require__'
     /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:in `require'
     /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:in
`require'
     /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/
active_support/dependencies.rb:214:in `require'
     ./script/server:3
4005a47a8f2ceee49670b920593c1d52?d=identicon&s=25 Ben Munat (Guest)
on 2006-02-13 18:32
(Received via mailing list)
Something in the session can't be serialized?

b
3ccecc71b9fb0a3d7f00a0bef6f0a63a?d=identicon&s=25 Kent Sibilev (Guest)
on 2006-02-13 18:37
(Received via mailing list)
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:in `binding'
        from :0
irb(main):004:0>

Kent.
4005a47a8f2ceee49670b920593c1d52?d=identicon&s=25 Ben Munat (Guest)
on 2006-02-13 21:23
(Received via mailing list)
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
This topic is locked and can not be replied to.