Skip to content
This repository was archived by the owner on Jul 13, 2025. It is now read-only.
This repository was archived by the owner on Jul 13, 2025. It is now read-only.

Changes to record in after_commit change transaction_changed_attributes #17

@dylanahsmith

Description

@dylanahsmith

The main use case for the gem is to get all the committed changes in the after_commit callback, however, changes to the record in the after_commit callbacks affect transaction_changed_attributes.

For instance, unsaved changes will be added to transaction_changed_attributes. If the record were saved in the after_commit callback, then transaction_changed_attributes would be cleared. If the changes happen in one after_commit callback then they will affect the following after_commit callbacks.

I actually noticed this problem while looking into a similar issue in active record with saved_changes where it isn't safe to assume that saved_changes in an after_save callback is giving the changes for the save that caused the callback to be called, since the record could have been saved in a preceding after save callback.

I would recommend avoiding changing the record in after commit callbacks as a workaround if anyone encounters this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions