-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
This commit fixes the following error:
class Door include Mongoid::Document has_one :door_key end class DoorKey include Mongoid::Document belongs_to :door end door = Door.new(door_key: DoorKey.new) door.save && door.door_key.save door.reload # now model doesn't know about its relation object door.door_key = DoorKey.new # previous model will not be detached door = Door.new(door_key: DoorKey.new) door.save && door.door_key.save door.reload door.door_key # now Door model knows about door_key relation door.door_key = DoorKey.new # previous model will be detached correctly # Collection dump: db.door_keys.find() { "_id" : ObjectId("507b22b2ea6683af09000002"), "door_id" : ObjectId("507b22b2ea6683af09000001") } { "_id" : ObjectId("507b22b2ea6683af09000003"), "door_id" : ObjectId("507b22b2ea6683af09000001") } { "_id" : ObjectId("507b22b2ea6683af09000005"), "door_id" : null } { "_id" : ObjectId("507b22b2ea6683af09000006"), "door_id" : ObjectId("507b22b2ea6683af09000004") }