mongoid/mongoid — Issue #1365: mongoid does not save hash of hashes
Author: dcu
Created: 2011-10-20 20:24:49+00:00
State: open

this is probably dup of #814 but it is still not working with mongoid 2.3:

ruby-1.9.2-p180 :092 > class TestHashes; include Mongoid::Document; field :atts, :type => Hash; end
=> #Hash}, @label=nil, @localize=nil, @default_val=nil, @cast_on_read=false>
ruby-1.9.2-p180 :093 > TestHashes.create(:atts => {:foo => {}})
ruby-1.9.2-p180 :095 > a = TestHashes.first
=> #{}}>
ruby-1.9.2-p180 :096 > a.atts["foo"]["bar"] = 10
=> 10
ruby-1.9.2-p180 :097 > a.save
=> true
ruby-1.9.2-p180 :098 > a.reload.atts
=> {"foo"=>{}}

ruby-1.9.2-p180 :099 > a.atts_will_change!
=> nil
ruby-1.9.2-p180 :100 > a.atts["foo"]["bar"] = 10
=> 10
ruby-1.9.2-p180 :101 > a.changes
=> {"atts"=>nil}
ruby-1.9.2-p180 :102 > a._updates
=> {}
ruby-1.9.2-p180 :103 > a.save
=> true
ruby-1.9.2-p180 :104 > a.reload.atts
=> {"foo"=>{}}
ruby-1.9.2-p180 :105 > Mongoid::VERSION => "2.3.1"