Make load_app_config more robust, point to the right folder in db seed
This commit is contained in:
parent
662071be08
commit
96aaf3093c
3 changed files with 14 additions and 10 deletions
|
|
@ -2,16 +2,20 @@
|
|||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
raw_config = File.read("#{Rails.root}/config/app_config.yml")
|
||||
all_envs = YAML.load(raw_config)
|
||||
|
||||
unless all_envs
|
||||
raw_config = File.read("#{Rails.root}/config/app_config_example.yml")
|
||||
all_envs = YAML.load(raw_config)
|
||||
def load_config_yaml filename
|
||||
YAML.load(File.read(filename))
|
||||
end
|
||||
|
||||
if all_envs[Rails.env]
|
||||
APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env]).symbolize_keys
|
||||
if File.exist? "#{Rails.root}/config/app_config.yml"
|
||||
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml"
|
||||
all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml" unless all_envs
|
||||
else
|
||||
puts "WARNING: No config/app_config.yml found! Look at config/app_config_example.yml for help."
|
||||
all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml"
|
||||
end
|
||||
|
||||
if all_envs[Rails.env.to_s]
|
||||
APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env.to_s]).symbolize_keys
|
||||
else
|
||||
APP_CONFIG = all_envs['default'].symbolize_keys
|
||||
end
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ def set_app_config username
|
|||
current_config[Rails.env.to_s] ||= {}
|
||||
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
|
||||
current_config['default']['pod_url'] = "#{username}.joindiaspora.com"
|
||||
file = File.new(Rails.root.join('..','shared','app_config.yml'),'w')
|
||||
file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w')
|
||||
file.write(current_config.to_yaml)
|
||||
file.close
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ def set_app_config username
|
|||
current_config[Rails.env.to_s] ||= {}
|
||||
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
|
||||
current_config['default']['pod_url'] = "#{username}.joindiaspora.com"
|
||||
file = File.new(Rails.root.join('..','shared','app_config.yml'),'w')
|
||||
file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w')
|
||||
file.write(current_config.to_yaml)
|
||||
file.close
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue