1

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?

Drew
  • 15,158
  • 17
  • 68
  • 77

1 Answers1

1

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

jjy
  • 66
  • 1
  • 5