Created
October 7, 2014 18:45
-
-
Save darthneel/a6465729ca4a5f1fa63c to your computer and use it in GitHub Desktop.
Sample environments.rb for pushing Sinatra + PSQL to Heroku
This file contains 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
#These Settings Establish the Proper Database Connection for Heroku Postgres | |
#The environment variable DATABASE_URL should be in the following format: | |
# => postgres://{user}:{password}@{host}:{port}/path | |
#This is automatically configured on Heroku, you only need to worry if you also | |
#want to run your app locally | |
require 'active_record' | |
configure :production, :development do | |
db = URI.parse(ENV['DATABASE_URL'] || 'postgres://localhost/projecttwo') | |
ActiveRecord::Base.establish_connection( | |
:adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme, | |
:host => db.host, | |
:username => db.user, | |
:password => db.password, | |
:database => db.path[1..-1], | |
:encoding => 'utf8' | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment