-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
We were trying to upgrade to Mongoid 2.2.0 and ran into the following bug. This behavior appears to have been introduced or refactored in 76d8692.
We have a relatively simple embedded one-to-many relationship between two models. When you attempt to assign the parent model to the child model via child_instance.parent = parent_instance, this attempts to save the child model. However, it appears that bind_one is not properly setting the parent association to the child instance. This bug was exposed because we have a validation in the child model (which gets executed due to the base.save if persistable? call on line 25 of relations/embedded/in.rb) that references a property on the parent model, and the parent model is returning nil.
I'll write a failing spec and submit a pull request to verify.