Merge pull request #4715 from consul/custom_settings

Make it easier to define custom settings
This commit is contained in:
Javi Martín
2021-10-29 14:40:52 +02:00
committed by GitHub

View File

@@ -0,0 +1,31 @@
require_dependency Rails.root.join("app", "models", "setting").to_s
class Setting
class << self
alias_method :consul_defaults, :defaults
# Change this code when you'd like to add settings that aren't
# already present in the database. These settings will be added when
# first installing CONSUL, when deploying code with Capistrano, or
# when manually executing the `settings:add_new_settings` task.
#
# If a setting already exists in the database, changing its value in
# this file will have no effect unless the task `rake db:seed` is
# invoked or the method `Setting.reset_defaults` is executed. Doing
# so will overwrite the values of all existing settings in the
# database, so use with care.
#
# The tests in the spec/ folder rely on CONSUL's default settings, so
# it's recommended not to change the default settings in the test
# environment.
def defaults
if Rails.env.test?
consul_defaults
else
consul_defaults.merge({
# Overwrite default CONSUL settings or add new settings here
})
end
end
end
end