-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
In my User model I have the following embedded relation:
embeds_one :test, autobuild: true
When I create a new instance of User, test is uninitialized (nil), so autobuild feature returns a new instance of Test class. So far so good. But when I've started using it, I've noticed it doesn't remember the 'state'.
For example, this doesn't work:
user = User.new
user.test.something = 1
puts user.test.something
This will print nil. Each time user.test is called, Mongoid will create a new instance of Test class.
My expectations were different - I thought it would create only one new instance and then return that instance in following calls.
Is this a bug or are my expectations wrong?