You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In short, an after_commit:if option is still triggered after the destroy lifecycle even if the after_commit is limited to, say, [:create, :update]. This doesn't seem like it should be expected behavior.
Since the after_commit is limited to being triggered on the create and update events, and therefore never be triggered on destroy events, it seems counter-intuitive for ActiveRecord to bother processing the :if option, and can cause errors if the code within the :if option assumes that it will only be run when the model is valid and existing.
Actual behavior
The after_commit:if option is triggered on destroy.
System configuration
Rails version: Gist reproduces this in 5.0.1. I discovered this issue in 4.2.7.
Ruby version: 2.3.1
The text was updated successfully, but these errors were encountered:
In short, an
after_commit
:if
option is still triggered after the destroy lifecycle even if theafter_commit
is limited to, say,[:create, :update]
. This doesn't seem like it should be expected behavior.Steps to reproduce
Here is a gist.
Expected behavior
Since the
after_commit
is limited to being triggered on the create and update events, and therefore never be triggered on destroy events, it seems counter-intuitive for ActiveRecord to bother processing the:if
option, and can cause errors if the code within the:if
option assumes that it will only be run when the model is valid and existing.Actual behavior
The
after_commit
:if
option is triggered on destroy.System configuration
Rails version: Gist reproduces this in 5.0.1. I discovered this issue in 4.2.7.
Ruby version: 2.3.1
The text was updated successfully, but these errors were encountered: