From fd24c37da46a5aee4844447f94a087b2db0916ff Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 2 May 2024 18:45:43 +0100 Subject: [PATCH] DEV: Add eager loading for scheduled jobs --- lib/my_plugin_module/engine.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/my_plugin_module/engine.rb b/lib/my_plugin_module/engine.rb index 26e035c..9b5710c 100644 --- a/lib/my_plugin_module/engine.rb +++ b/lib/my_plugin_module/engine.rb @@ -5,5 +5,9 @@ class Engine < ::Rails::Engine engine_name PLUGIN_NAME isolate_namespace MyPluginModule config.autoload_paths << File.join(config.root, "lib") + scheduled_job_dir = "#{config.root}/app/jobs/scheduled" + config.to_prepare do + Rails.autoloaders.main.eager_load_dir(scheduled_job_dir) if Dir.exist?(scheduled_job_dir) + end end end