Skip to content

Instantly share code, notes, and snippets.

@elvio
Last active December 19, 2015 19:38
Show Gist options
  • Save elvio/6007036 to your computer and use it in GitHub Desktop.
Save elvio/6007036 to your computer and use it in GitHub Desktop.
if ENV["DATABASE_URL"]
db = URI.parse(ENV["DATABASE_URL"])¬
db_scheme = db.scheme == 'postgres' ? 'postgresql' : db.scheme¬
options = {¬
:adapter => db_scheme,¬
:host => db.host,¬
:username => db.user,¬
:password => db.password,¬
:database => db.path[1..-1],¬
:encoding => 'utf8'¬
else
options = {¬
:adapter => 'postgresql',¬
:database => 'tweektv_test',¬
:encoding => 'utf8'¬
ActiveRecord::Base.establish_connection(options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment