-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
Since commit 5a1f8f3b5256af3cfb3d3fc99737c37a3660591e (RE: MONGOID-2943), binding of a referenced-in relation no longer works right, because the inverse relation is set to the document itself rather than a relation proxy wrapping it:
class Parent include Mongoid::Document has_one :child, inverse_of: :parent end class Child include Mongoid::Document belongs_to :parent, inverse_of: :child end parent = Parent.new child = Child.new child.parent = parent parent.child = nil # or parent.child = Child.new — same thing happens # => NoMethodError: undefined method `substitute' for #<Child:0x007f92b6a52be8>
I've reverted the commit in my own fork, but obviously that's not a good solution as it returns the extra query on has_one relations.
/cc arthurnn