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

Nil-Value with embedded_in and field-type Array

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

      I've created a Rails3 Repo with a rspec-test to illustrate the problem here: https://github.com/QEDio/mongoid_error.
      Clone, bundle install, rake.

      In short

      class Computer
      include Mongoid::Document
      embeds_many :parts
      end

      class Part
      include Mongoid::Document
      embedded_in :computer

      field :description1, type: Array
      field :description2
      end

      This fails:

      computer = Computer.new
      part = Part.new

      computer.parts << part
      computer.save

      part.description1 = PART_DATA1
      part.save

      part.description1 = PART_DATA2
      part.save

      ==> now part.description1 is null (in the db)

            Assignee:
            durran Durran Jordan
            Reporter:
            jak4 jak4
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: