Commit 19b2c04990f78225bf4c5d59decf4e3da36ab42a

Authored by alex@liivid.com
1 parent 6c80863f
Exists in master and in 1 other branch production

Load heroku values always if they are available, then override with config.yml

Showing 1 changed file with 13 additions and 12 deletions   Show diff stats
config/initializers/_load_config.rb
1 require 'ostruct' 1 require 'ostruct'
2 2
3 -config_file = Rails.root.join('config', Rails.env == "test" ? "config.example.yml" : "config.yml")  
4 -Errbit::Config = nil # assign global scope  
5 -if File.exists?(config_file)  
6 - yaml = File.read(config_file)  
7 - config = YAML.load(yaml) 3 +Errbit::Config = OpenStruct.new
8 4
9 - config.merge!(config.delete(Rails.env)) if config.has_key?(Rails.env)  
10 -  
11 - Errbit::Config = OpenStruct.new(config)  
12 -elsif ENV['HEROKU']  
13 - Errbit::Config = OpenStruct.new 5 +if ENV['HEROKU']
14 Errbit::Config.host = ENV['ERRBIT_HOST'] 6 Errbit::Config.host = ENV['ERRBIT_HOST']
15 Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM'] 7 Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM']
16 Errbit::Config.email_at_notices = [1,3,10] #ENV['ERRBIT_EMAIL_AT_NOTICES'] 8 Errbit::Config.email_at_notices = [1,3,10] #ENV['ERRBIT_EMAIL_AT_NOTICES']
@@ -22,8 +14,17 @@ elsif ENV['HEROKU'] @@ -22,8 +14,17 @@ elsif ENV['HEROKU']
22 :password => ENV['SENDGRID_PASSWORD'], 14 :password => ENV['SENDGRID_PASSWORD'],
23 :domain => ENV['SENDGRID_DOMAIN'] 15 :domain => ENV['SENDGRID_DOMAIN']
24 } 16 }
25 -else  
26 - raise("Missing config file #{config_file}") 17 +end
  18 +
  19 +config_file = Rails.root.join('config', Rails.env == "test" ? "config.example.yml" : "config.yml")
  20 +
  21 +if File.exists?(config_file)
  22 + yaml = File.read(config_file)
  23 + config = YAML.load(yaml)
  24 + config.merge!(config.delete(Rails.env)) if config.has_key?(Rails.env)
  25 + config.each do |k,v|
  26 + Errbit::Config.send("#{k}=", v)
  27 + end
27 end 28 end
28 29
29 # Set config specific values 30 # Set config specific values