From 1bfc2219d422741be71d85ad6c5dff2f199fcba9 Mon Sep 17 00:00:00 2001 From: Douglas Berkley Date: Sun, 21 Jun 2026 11:21:34 +0700 Subject: [PATCH] after_commit callbacks stay permanently deactivated for the rest of that process's lifetime --- app/services/database_views.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/services/database_views.rb b/app/services/database_views.rb index f26b740..9c2db6b 100644 --- a/app/services/database_views.rb +++ b/app/services/database_views.rb @@ -20,7 +20,12 @@ def self.activate_callback(then_refresh: false) def self.run_without_callback(then_refresh: false, &block) deactivate_callback - yield - activate_callback(then_refresh: then_refresh) + completed = false + begin + yield + completed = true + ensure + activate_callback(then_refresh: completed && then_refresh) + end end end