Skip to content

Commit

Permalink
Support for config.yml on heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
crystalneth committed Aug 11, 2011
1 parent 5884c15 commit 6c80863
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions config/initializers/_load_config.rb
@@ -1,6 +1,15 @@
require 'ostruct'

if ENV['HEROKU']
config_file = Rails.root.join('config', Rails.env == "test" ? "config.example.yml" : "config.yml")
Errbit::Config = nil # assign global scope
if File.exists?(config_file)
yaml = File.read(config_file)
config = YAML.load(yaml)

config.merge!(config.delete(Rails.env)) if config.has_key?(Rails.env)

Errbit::Config = OpenStruct.new(config)
elsif ENV['HEROKU']
Errbit::Config = OpenStruct.new
Errbit::Config.host = ENV['ERRBIT_HOST']
Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM']
Expand All @@ -14,13 +23,7 @@
:domain => ENV['SENDGRID_DOMAIN']
}
else
config_file = Rails.env == "test" ? "config.example.yml" : "config.yml"
yaml = File.read(Rails.root.join('config', config_file))
config = YAML.load(yaml)

config.merge!(config.delete(Rails.env)) if config.has_key?(Rails.env)

Errbit::Config = OpenStruct.new(config)
raise("Missing config file #{config_file}")
end

# Set config specific values
Expand Down

0 comments on commit 6c80863

Please sign in to comment.