From 5f05c741f216a61beddaed506670381db5c6425d Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 20 Dec 2012 11:34:45 +0100 Subject: Loading config defaults from default.yml now You can overwrite them in config/config.yml --- config/initializers/load_config.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'config/initializers/load_config.rb') diff --git a/config/initializers/load_config.rb b/config/initializers/load_config.rb index e687429..6cfde12 100644 --- a/config/initializers/load_config.rb +++ b/config/initializers/load_config.rb @@ -1 +1,7 @@ -APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env] +def load_config_file(file) + File.exists?(file) ? YAML.load_file(file)[Rails.env] : {} +end + +defaults = load_config_file("#{Rails.root}/config/defaults.yml") +config = load_config_file("#{Rails.root}/config/config.yml") +APP_CONFIG = defaults.merge(config) -- cgit v1.2.3 From 54037816896a9347c5894ad8260e440bba43d14f Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 20 Dec 2012 12:46:06 +0100 Subject: config hash now has indifferent access --- config/initializers/load_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/initializers/load_config.rb') diff --git a/config/initializers/load_config.rb b/config/initializers/load_config.rb index 6cfde12..a3dbc5f 100644 --- a/config/initializers/load_config.rb +++ b/config/initializers/load_config.rb @@ -4,4 +4,4 @@ end defaults = load_config_file("#{Rails.root}/config/defaults.yml") config = load_config_file("#{Rails.root}/config/config.yml") -APP_CONFIG = defaults.merge(config) +APP_CONFIG = defaults.merge(config).with_indifferent_access -- cgit v1.2.3