From cca0a5af47338f1a46dd6debd9991366b230d613 Mon Sep 17 00:00:00 2001 From: adi-herwana-nus Date: Mon, 24 Aug 2026 04:04:22 +0800 Subject: [PATCH] chore(rails): wrap perform_later jobs in explicit after_commit blocks --- .../course/users_controller_management_concern.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/concerns/course/users_controller_management_concern.rb b/app/controllers/concerns/course/users_controller_management_concern.rb index 0210c642a00..9fcd4af2c47 100644 --- a/app/controllers/concerns/course/users_controller_management_concern.rb +++ b/app/controllers/concerns/course/users_controller_management_concern.rb @@ -90,7 +90,9 @@ def suspend to_notify = to_suspend.reject(&:is_suspended?) to_suspend.update_all(is_suspended: true) - to_notify.each { |cu| Course::Mailer.user_suspended_email(cu).deliver_later } + ActiveRecord.after_all_transactions_commit do + to_notify.each { |cu| Course::Mailer.user_suspended_email(cu).deliver_later } + end head :ok end @@ -107,7 +109,9 @@ def unsuspend to_notify = to_unsuspend.select(&:is_suspended?) to_unsuspend.update_all(is_suspended: false) - to_notify.each { |cu| Course::Mailer.user_unsuspended_email(cu).deliver_later } + ActiveRecord.after_all_transactions_commit do + to_notify.each { |cu| Course::Mailer.user_unsuspended_email(cu).deliver_later } + end head :ok end