-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
Hi, I've got this document:
class CourierJob
include Mongoid::Document
embeds_one :drop_address, as: :addressable, autobuild: true, class_name: "Addresses::ShipmentAddress"
end
now when i execute
(:drop_address, some address object)
on a CourierJob instance I can see the following in the rails logfile:
MOPED: 127.0.0.1:27017 UPDATE database=project_test collection=courier_jobs selector=
{"_id"=>BSON::ObjectId('537e0b50476f6c1b19190000')}update={"$set"=>{"address"=>
{"_id"=>BSON::ObjectId('537e0b50476f6c1b191c0000'), "_type"=>"Addresses::ShipmentAddress", ....}}}
The part i am worried about is
={"$set"=>{"address"=>
because it should be
={"$set"=>{"drop_address"=>
The address model looks like this:
class Address
include Mongoid::Document
embedded_in :addressable, polymorphic: true
end
class ShipmentAddress < Address
...
end
Is there something I am doing wrong or is this a bug?
PS: if i do
.drop_address
on the same object right after the
it gives me the correct result. After a reload from the db the the value is again the one from before
update_attribute{{`}}
- tested by
-
MONGOID-3661 Failing spec for issue MONGOID-3659
- Closed