From 580889a34ecb85d8403fe8cedb70cd07ba8b075a Mon Sep 17 00:00:00 2001 From: merefield Date: Mon, 17 Jul 2023 10:16:27 +0100 Subject: [PATCH] move destroy logic into library method & transaction --- app/controllers/custom_wizard/admin/wizard.rb | 2 -- lib/custom_wizard/template.rb | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/custom_wizard/admin/wizard.rb b/app/controllers/custom_wizard/admin/wizard.rb index 6737da6c..08e7b6d0 100644 --- a/app/controllers/custom_wizard/admin/wizard.rb +++ b/app/controllers/custom_wizard/admin/wizard.rb @@ -26,8 +26,6 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController def remove if CustomWizard::Template.remove(@wizard.id) - related_custom_fields = CategoryCustomField.where(name: 'create_topic_wizard', value: @wizard.name) - related_custom_fields.destroy_all render json: success_json else render json: failed_json diff --git a/lib/custom_wizard/template.rb b/lib/custom_wizard/template.rb index 12a86bf6..59a9998e 100644 --- a/lib/custom_wizard/template.rb +++ b/lib/custom_wizard/template.rb @@ -64,6 +64,8 @@ class CustomWizard::Template ensure_wizard_upload_references!(wizard_id) PluginStore.remove(CustomWizard::PLUGIN_NAME, wizard.id) clear_user_wizard_redirect(wizard_id, after_time: !!wizard.after_time) + related_custom_fields = CategoryCustomField.where(name: 'create_topic_wizard', value: wizard.name) + related_custom_fields.destroy_all end clear_cache_keys