allow to set some configuration options via ENV
This commit is contained in:
parent
8f3973bbff
commit
b0644b26c7
|
@ -1,5 +1,23 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Auxiliary config
|
# Auxiliary config
|
||||||
APP_CONFIG = YAML.load_file(Rails.root.join('config', 'justask.yml')).with_indifferent_access
|
|
||||||
|
APP_CONFIG = {}.with_indifferent_access
|
||||||
|
|
||||||
|
# load yml config if it's present
|
||||||
|
justask_yml_path = Rails.root.join("config/justask.yml")
|
||||||
|
APP_CONFIG.merge!(YAML.load_file(justask_yml_path)) if File.exist?(justask_yml_path)
|
||||||
|
|
||||||
|
# load config from ENV where possible
|
||||||
|
env_config = {
|
||||||
|
# The site name, shown everywhere
|
||||||
|
site_name: ENV.fetch("SITE_NAME", nil),
|
||||||
|
|
||||||
|
hostname: ENV.fetch("HOSTNAME", nil),
|
||||||
|
}.compact
|
||||||
|
APP_CONFIG.merge!(env_config)
|
||||||
|
|
||||||
# Update rails config for mail
|
# Update rails config for mail
|
||||||
Rails.application.config.action_mailer.default_url_options = { host: APP_CONFIG['hostname'] }
|
Rails.application.config.action_mailer.default_url_options = {
|
||||||
|
host: APP_CONFIG["hostname"],
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue