Commit 6c80863ff265842860aa43f2f0babb969e68b4ff

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

Support for config.yml on heroku

Showing 1 changed file with 11 additions and 8 deletions   Show diff stats
config/initializers/_load_config.rb
1 1 require 'ostruct'
2 2  
3   -if ENV['HEROKU']
  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)
  8 +
  9 + config.merge!(config.delete(Rails.env)) if config.has_key?(Rails.env)
  10 +
  11 + Errbit::Config = OpenStruct.new(config)
  12 +elsif ENV['HEROKU']
4 13 Errbit::Config = OpenStruct.new
5 14 Errbit::Config.host = ENV['ERRBIT_HOST']
6 15 Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM']
... ... @@ -14,13 +23,7 @@ if ENV['HEROKU']
14 23 :domain => ENV['SENDGRID_DOMAIN']
15 24 }
16 25 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)
20   -
21   - config.merge!(config.delete(Rails.env)) if config.has_key?(Rails.env)
22   -
23   - Errbit::Config = OpenStruct.new(config)
  26 + raise("Missing config file #{config_file}")
24 27 end
25 28  
26 29 # Set config specific values
... ...