Skip to content

Instantly share code, notes, and snippets.

@drewinglis
Created April 7, 2012 18:25
Show Gist options
  • Save drewinglis/2331149 to your computer and use it in GitHub Desktop.
Save drewinglis/2331149 to your computer and use it in GitHub Desktop.
Connect to Postgres on Heroku
require 'yaml'
require 'sequel'
if ENV['DATABASE_URL']
@database = Sequel.connect(ENV['DATABASE_URL'])
else
file = File.read("#{Rails.root}/config/database.yml")
config = YAML.load(file)
config = config[Rails.env]
config.symbolize_keys!
config[:adapter] = "postgres"
@database = ::Sequel.connect(config)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment