-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
ruby require 'spec_helper' class Sandwich include Mongoid::Document embeds_many :slices end class Slice include Mongoid::Document field :position, default: 0 include Mongoid::Document embedded_in :sandwiches embeds_one :measure end class Measure include Mongoid::Document field :thickness embedded_in :slice end describe "relationship" do it "uses a positional operator" do sandwich = Sandwich.create! slice = Slice.new sandwich.slices << slice Moped.logger = Logger.new(STDOUT) Moped.logger.level = Logger::DEBUG slice.measure = Measure.new end end
MOPED: 127.0.0.1:27017 UPDATE database=mongoid_test collection=sandwiches selector={"_id"=>"510af81c3b55524e16000001", "slices._id"=>"510af81c3b55524e16000002"} update={"$set"=>{"slices.0.measure"=>{"_id"=>"510af81c3b55524e16000003"}}} flags=[]
The Measure is embedded in Slice, which should behave just like any other field that can be set. This should be slices.$.measure for both $set and $unset.