class Car
include Mongoid::Document
embeds_one :seat
field :a
end
class Seat
include Mongoid::Document
embedded_in :car
field :a
validates_presence_of :car
end
> c=Car.new
> c.build_seat
> c.save
MOPED: 127.0.0.1:27017 INSERT database=x collection=cars documents=[{"_id"=>"520a9f5f530a6941c1000001", "seat"=>{"_id"=>"520a9f61530a6941c1000002"}}] flags=[] (0.0660ms)
> c.seat.a='foo'
> c.save
MOPED: 127.0.0.1:27017 UPDATE database=x collection=cars selector={"_id"=>"520a9f5f530a6941c1000001", "seat._id"=>"520a9f61530a6941c1000002"} update={"$set"=>{"seat.a"=>"foo"}} flags=[] (0.1171ms)
MOPED: 127.0.0.1:27017 UPDATE database=x collection=cars selector={"_id"=>"520a9f5f530a6941c1000001"} update={"$set"=>{"seat.a"=>"foo"}} flags=[] (0.0908ms)