Created
September 18, 2012 11:53
-
-
Save letmein/3742752 to your computer and use it in GitHub Desktop.
Read database config from database.yml in a padrino app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On Heroku we'll read the config from ENV | |
if postgres = URI.parse(ENV['DATABASE_URL'] || '') | |
ActiveRecord::Base.configurations[:production] = { | |
:adapter => 'postgresql', | |
:encoding => 'utf8', | |
:database => postgres.path[1..-1], | |
:username => postgres.user, | |
:password => postgres.password, | |
:host => postgres.host | |
} | |
else | |
YAML.load_file("#{Padrino.root}/config/database.yml").each do |env, conf| | |
ActiveRecord::Base.configurations[env.to_sym] = conf.symbolize_keys | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment