From e6bfec5bdb51a0e98ea6c5da9ee8546a2c617bca Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 2 May 2024 18:53:22 +0100 Subject: [PATCH] DEV: Update engine config to match skeleton - adds `lib/` autoloading (and removes the plugin.rb workaround) - adds eager loading of scheduled jobs in development (otherwise they don't work at all) --- lib/engine.rb | 5 +++++ plugin.rb | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/engine.rb b/lib/engine.rb index 6c43e22e..89dc865c 100644 --- a/lib/engine.rb +++ b/lib/engine.rb @@ -4,5 +4,10 @@ module ::DiscourseAi class Engine < ::Rails::Engine engine_name PLUGIN_NAME isolate_namespace DiscourseAi + 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 diff --git a/plugin.rb b/plugin.rb index b90801d7..9ca38252 100644 --- a/plugin.rb +++ b/plugin.rb @@ -30,8 +30,6 @@ module ::DiscourseAi PLUGIN_NAME = "discourse-ai" end -Rails.autoloaders.main.push_dir(File.join(__dir__, "lib"), namespace: ::DiscourseAi) - require_relative "lib/engine" after_initialize do