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

Embedded document doesn't save Array fields in Mongoid 2.4.0

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

      I have updated mongoid 2.3.4 -> 2.4.0 and got this bug:

      class Character
        include Mongoid::Document
        embeds_one :stats, :class_name => 'Stats'
      end
      
      class Stats
        include Mongoid::Document
        field :directions,  :type => Array
        embedded_in :character
      end
      
      1.9.3p0 :010 > cc = Character.first.stats
       => #<Stats _id: 4f071ee09759f7826800001d, _type: nil, directions: nil> 
      1.9.3p0 :011 > cc.directions = [2, 3, 6, 2] 
       => [2, 3, 6, 2] 
      1.9.3p0 :012 > cc.save
       => true 
      1.9.3p0 :013 > cc
       => #<Stats _id: 4f071ee09759f7826800001d, _type: nil, directions: [2, 3, 6, 2]> 
      1.9.3p0 :014 > cc = Character.first.stats
       => #<Stats _id: 4f071ee09759f7826800001d, _type: nil, directions: nil> 
      

      When I went back to mongoid 2.3.4 and repeat these steps, I got expected result:

      1.9.3p0 :001 > cc = Character.first.stats
       => #<Stats _id: 4f071ee09759f7826800001d, _type: nil, directions: nil> 
      1.9.3p0 :002 > c.directions = [4, 0, 7, 1]
       => [4, 0, 7, 1] 
      1.9.3p0 :003 > cc.save
       => true 
      1.9.3p0 :004 > cc
       => #<Stats _id: 4f071ee09759f7826800001d, _type: nil, directions: [4, 0, 7, 1]> 
      1.9.3p0 :005 > cc = Character.first.stats
       => #<Stats _id: 4f071ee09759f7826800001d, _type: nil, directions: [4, 0, 7, 1]> 
      

            Assignee:
            durran Durran Jordan
            Reporter:
            mik-die Mikhail Dieterle
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: