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

Do not invoke callbacks on unchanged children when autosaving

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Callbacks
    • None

      When autosaving is turned on for the child associations (e.g. when using accepts_nested_attributes_for),
      when the parent document is loaded and saved after some attribute changes, all child documents are also saved (i.e. taken through the persistence process) even though none of the children changed.

      The child saves don't write anything to the database but go through the full persistence process on the client side including after_save callback invocations.

      For example, if user has many posts, and posts are autosaved, changing an attribute on user would result in after_save callback being called on each post of that user.

      Since none of the children changed, they shouldn't be going through the persistence process.

            Assignee:
            Unassigned Unassigned
            Reporter:
            pgdstryr@gmail.com Rob Lacey
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: