Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 7.1 after commit callback order #2713

Closed
codez opened this issue Dec 1, 2023 · 2 comments
Closed

Rails 7.1 after commit callback order #2713

codez opened this issue Dec 1, 2023 · 2 comments

Comments

@codez
Copy link

codez commented Dec 1, 2023

Rails 7.1 has a new default that runs after_commit callbacks in the order they are defined.

new_framework_defaults_7_1.rb:

# Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model.
# This matches the behaviour of all other callbacks.
# In previous versions of Rails, they ran in the inverse order.
#++
Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true

This causes previously stored files not to be removed when they are updated, because after_commit :"remove_previously_stored_#{column}", on: :update runs after after_commit :"reset_previous_changes_for_#{column}" (which resets the @removed_uploaders).

As a workaround, the above configuration can be set to false, but it would be nice if carrierwave could handle this. Probably it's enough to check the configuration and define the callbacks the other way around.

@codez codez changed the title Rails 7.1 After commit callback order Rails 7.1 after commit callback order Dec 1, 2023
@mshibuya
Copy link
Member

mshibuya commented Dec 3, 2023

Thank you for reporting, now fixed in the master!

@codez
Copy link
Author

codez commented Dec 4, 2023

Great, thank you very much for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants