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

You can't add multiple embedded documents that are in embedded documents

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

      class Test1
        include Mongoid::Document
        embeds_many :test2
      end
      
      class Test2
        include Mongoid::Document
        embedded_in :test1
        embeds_many :test3
      end
      
      class Test3
        include Mongoid::Document
        embedded_in :test2
      end
      
      # This all works fine
      t = Test1.create
      t.test2 << Test2.new
      t.test2.first.test3.new
      t.changed?
      # => true
      t.save
      
      # This will now do nothing
      t.test2.first.test3.new
      t.changed?
      # => false
      t.test2.first.changed?
      # => false
      t.save
      # returns true, yet it does nothing -- this is extremely dangerous/bad
      t.test2.first.test3.last.persisted?
      # => false
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            jonhyman Jon Hyman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: