Skip to content

Instantly share code, notes, and snippets.

@mipearson
Created July 29, 2012 01:49
Show Gist options
  • Select an option

  • Save mipearson/3195668 to your computer and use it in GitHub Desktop.

Select an option

Save mipearson/3195668 to your computer and use it in GitHub Desktop.
Example of environment / URI driven database.yml
<%
if ENV['DATABASE_URL']
db_uri = URI.parse(ENV['DATABASE_URL']) %>
production:
adapter: <%= db_uri.scheme) %>
database: <%= db_uri.path %>
username: <%= db_uri.username %>
<% if db_uri.password %>
password: <%= db_uri.password %>
<% end %>
host: <%= db_uri.host %>
<% if db_uri.port %>
port: <%= db_uri.port %>
<% end %>
<% else %>
production:
adapter: mysql2
database: XXX
username: XXX
password: XXX
host: localhost
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment