Skip to content

Instantly share code, notes, and snippets.

@linki
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save linki/67c91554906c22457895 to your computer and use it in GitHub Desktop.

Select an option

Save linki/67c91554906c22457895 to your computer and use it in GitHub Desktop.
<%
# default database without credentials, suffixed with env
def default_database(env)
"postgres://localhost:5432/openproject_#{env}?encoding=unicode&pool=5"
end
# first checks if there's an env var defining the database
# then falls back to using the default database for the env
def database(env)
ENV.fetch('DATABASE_URL') { default_database(env) }
end
%>
default: &default
url: <%= database(Rails.env) %>
development:
<<: *default
test:
<<: *default
production:
<<: *default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment