Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4425

changes in callbacks of an embedded document not persisted.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 6.1.1
    • Affects Version/s: 6.0.3
    • Component/s: None
    • None
    • Environment:
      Mac OS 10.12.3

      hi guys.

      I just upgraded our project from mongoid 5.1.4 to 6.0.3. And we got a bunch of tests failing. It looks like if you have an embedded document with before_validation callbacks, changes in the before_validation callbacks are not persisted anymore if you run a update_attributes on the parent model object.

      The changes are persisted alright with mongoid 5.1.4. So I guess this is a new change in version 6.x?

      Is this an expected behaviour? or we are doing something wrong here?

      I added a PR for this ( https://github.com/mongodb/mongoid/pull/4398 )

      In this PR, I added a before_validation on the book page model, and two specs for it. The one with database reloading is failing.

      (I know for this test, you could use a default value to replace the before_validation. But this spec is not talking about the business logic. It's just an example.)

      Thanks a lot in advanced.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            flankerfc@gmail.com FENG Zhichao
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: