Commit cc63d678317e7fa7c7552cda163dbcec0b183012

Authored by Nathan B
2 parents f9109d36 19b2c049
Exists in master and in 1 other branch production

Merge pull request #61 from aliix/master

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