From a375653669c00880da03bf5690832ac02dfb94c2 Mon Sep 17 00:00:00 2001 From: Kohei Suzuki Date: Fri, 31 Mar 2023 18:58:45 +0900 Subject: [PATCH] Load custom tasks and extensions after Zeitwerk is setup --- lib/kuroko2/engine.rb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/kuroko2/engine.rb b/lib/kuroko2/engine.rb index 6ca7a94a..86a6de4a 100644 --- a/lib/kuroko2/engine.rb +++ b/lib/kuroko2/engine.rb @@ -30,17 +30,6 @@ class Engine < ::Rails::Engine config.active_record.table_name_prefix = Kuroko2.config.table_name_prefix - if Kuroko2.config.custom_tasks - Kuroko2.config.custom_tasks.each do |key, klass| - unless Workflow::Node::TASK_REGISTRY.has_key?(key) - Workflow::Node.register( - key: key.to_sym, - klass: Workflow::Task.const_get(klass, false) - ) - end - end - end - config.action_mailer.default_url_options = { host: Kuroko2.config.url_host, protocol: Kuroko2.config.url_scheme, @@ -52,6 +41,19 @@ class Engine < ::Rails::Engine Kuroko2.config.action_mailer.smtp_settings.to_h.symbolize_keys || {} app.config.assets.precompile += %w(kuroko2/kuroko-logo-success.png kuroko2/kuroko-logo-error.png) + end + + config.after_initialize do + if Kuroko2.config.custom_tasks + Kuroko2.config.custom_tasks.each do |key, klass| + unless Workflow::Node::TASK_REGISTRY.has_key?(key) + Workflow::Node.register( + key: key.to_sym, + klass: Workflow::Task.const_get(klass, false) + ) + end + end + end if Kuroko2.config.extensions && Kuroko2.config.extensions.controller Kuroko2.config.extensions.controller.each do |extension|