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

Object is still on the parent's relation after being destroyed

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 6.0.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Hi,

      Some callback circular reference is taking my sleep today.

      After destroying a child in a referenced relation and updating the parent in a after_destroy callback triggers the destroyed object validation callback.

      I know it is hard to understand, so I put a simple app to reproduce the issue.
      https://github.com/felipero/mongoid_broken_destroy

      To spoil the problem:

      Article.create!(name: 'Everything was fine before master from mongoid', comments: [Comment.new])
      comment = Comment.first
      comment.destroy
      

      results in:

      RuntimeError:
             can't modify frozen BSON::Document
      
      

      Cloning the demo app and running the specs will show this behavior.

            Assignee:
            Unassigned Unassigned
            Reporter:
            felipero Felipe Rodrigues de Almeida
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: