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)
This commit is contained in:
David Taylor 2024-05-02 18:53:22 +01:00
parent b52d3c7d29
commit e6bfec5bdb
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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