Reputation: 15438
Not sure if this a Mongoid specific thing or if applies to the greater active record pattern. I have the following chunk of code, which works:
submission.reload.profile
submission.milestone = self.milestone
submission.profile = @profile
@profile.save && submission.save
The relation gets updated correctly. However, if I take out the first line (which I only arrived out through trial and error) it stops working and the relation does not update.
Why?
Upvotes: 1
Views: 93
Reputation: 66
May be submission have some invalid attributes, when you reload, submission back to validate state and can be saved. try p submission.errors after save without reload
Upvotes: 1