Skip to content

Instantly share code, notes, and snippets.

@letmein
Created September 18, 2012 11:53
Show Gist options
  • Save letmein/3742752 to your computer and use it in GitHub Desktop.
Save letmein/3742752 to your computer and use it in GitHub Desktop.
Read database config from database.yml in a padrino app
# 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