mongoid/mongoid — Issue #1593: Nil-Value with embedded_in and field-type Array
Author: jak4
Created: 2012-01-14 21:21:00+00:00
State: open

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)