Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #32489 - setting load on code reload #8526

Merged
merged 1 commit into from Jun 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions config/initializers/foreman.rb
Expand Up @@ -20,8 +20,8 @@
if (Setting.table_exists? rescue(false))
# in this phase, the classes are not fully loaded yet, load them
Dir[
File.join(Rails.root, "app/models/setting.rb"),
File.join(Rails.root, "app/models/setting/*.rb"),
Rails.root.join('app', 'models', 'setting.rb'),
Rails.root.join('app', 'models', 'setting', '*.rb'),
].each do |f|
require_dependency(f)
end
Expand All @@ -42,8 +42,17 @@
Foreman::Plugin.medium_providers_registry.register MediumProviders::Default

Rails.application.config.to_prepare do
# Force reload settings after all plugins have loaded and on code reload
Foreman.settings.load if (Setting.table_exists? rescue(false))
if (Setting.table_exists? rescue(false))
# Force reload settings after all plugins have loaded and on code reload
Dir[
Rails.root.join('app', 'models', 'setting.rb'),
Rails.root.join('app', 'models', 'setting', '*.rb'),
*Foreman::Plugin.registered_plugins.map { |_n, p| p.engine&.root&.join('app', 'models', 'setting', '*.rb') }.compact
].each do |f|
require_dependency(f)
end
Foreman.settings.load
end

Foreman.input_types_registry.register(InputType::UserInput)
Foreman.input_types_registry.register(InputType::FactInput)
Expand Down