Make load_app_config more robust, point to the right folder in db seed

This commit is contained in:
ilya 2010-09-21 18:04:36 -07:00
parent 662071be08
commit 96aaf3093c
3 changed files with 14 additions and 10 deletions

View file

@ -2,16 +2,20 @@
# licensed under the Affero General Public License version 3. See # licensed under the Affero General Public License version 3. See
# the COPYRIGHT file. # the COPYRIGHT file.
raw_config = File.read("#{Rails.root}/config/app_config.yml") def load_config_yaml filename
all_envs = YAML.load(raw_config) YAML.load(File.read(filename))
unless all_envs
raw_config = File.read("#{Rails.root}/config/app_config_example.yml")
all_envs = YAML.load(raw_config)
end end
if all_envs[Rails.env] if File.exist? "#{Rails.root}/config/app_config.yml"
APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env]).symbolize_keys 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 else
APP_CONFIG = all_envs['default'].symbolize_keys APP_CONFIG = all_envs['default'].symbolize_keys
end end

View file

@ -46,7 +46,7 @@ def set_app_config username
current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s] ||= {}
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
current_config['default']['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.write(current_config.to_yaml)
file.close file.close
end end

View file

@ -11,7 +11,7 @@ def set_app_config username
current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s] ||= {}
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
current_config['default']['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.write(current_config.to_yaml)
file.close file.close
end end