I'm building an Shopping Cart for my site and I having one trouble with rails session and ActiveRecord Objects:
Shopping Cart is actually one Order object with some OrderItems.
After add Order object to session, Dalli started raise this exception:
Marshalling error for key 'sessions:9e67886e826819a3213df4f4c89db6e0': can't dump hash with default proc
You are trying to cache a Ruby object which cannot be serialized to memcached.
/home/rodrigo/.rvm/gems/ruby-1.9.3-p125@netsabe-ecommerce/gems/dalli-2.1.0/lib/dalli/server.rb:277:in `dump'
/home/rodrigo/.rvm/gems/ruby-1.9.3-p125@netsabe-ecommerce/gems/dalli-2.1.0/lib/dalli/server.rb:277:in `serialize'
/home/rodrigo/.rvm/gems/ruby-1.9.3-p125@netsabe-ecommerce/gems/dalli-2.1.0/lib/dalli/server.rb:164:in `set'
/home/rodrigo/.rvm/gems/ruby-1.9.3-p125@netsabe-ecommerce/gems/dalli-2.1.0/lib/dalli/server.rb:48:in `request'
/home/rodrigo/.rvm/gems/ruby-1.9.3-p125@netsabe-ecommerce/gems/dalli-2.1.0/lib/dalli/options.rb:18:in `block in request'
/home/rodrigo/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/rodrigo/.rvm/gems/ruby-1.9.3-p125@netsabe-ecommerce/gems/dalli-2.1.0/lib/dalli/options.rb:17:in `request'
/home/rodrigo/.rvm/gems/ruby-1.9.3-p125@netsabe-ecommerce/gems/dalli-2.1.0/lib/dalli/client.rb:251:in `perform'
/home/rodrigo/.rvm/gems/ruby-1.9.3-p125@netsabe-ecommerce/gems/dalli-2.1.0/lib/dalli/client.rb:120:in `set'
/home/rodrigo/.rvm/gems/ruby-1.9.3-p125@netsabe-ecommerce/gems/dalli-2.1.0/lib/action_dispatch/middleware/session/dalli_store.rb:50:in `set_session'
Googling, I found that ActiveRecord can not be stored on session.
So, how is the best way to store this objects on session? I will have to implement serialize/deserialize methods for these classes?
Thank you!
EDIT 1:
Remembering that Order object isn't persisted yet!