Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1367

mongoid does not save hash of hashes

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.4.0
    • Affects Version/s: None
    • Component/s: None

      this is probably dup of MONGOID-815 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
      => #<Mongoid::Fields::Serializable::Hash:0x0000000c91e4c8 @name="atts", @options={:type=>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
      => #<TestHashes _id: 4ea082122c54793154000005, _type: nil, atts: {"foo"=>{}}>
      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"

            Assignee:
            durran Durran Jordan
            Reporter:
            dcu David Cuadrado
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: