Ensure DATABASE_URL is not ignored when database.yml isn't loaded #6833

Closed
wants to merge 2 commits into
from

Projects

None yet

5 participants

@MacksMind
Contributor

Currently specifying an environment name when DATABASE_URL is present
prevents a sucessful connection. Passing a string such as "production"
causes DATABASE_URL to be ignored because
ActiveRecord::Base.establish_connection only uses it if no name is
passed, but database.yml isn't loaded by the initializer if DATABASE_URL
is defined.

This change causes the resolver to use DATABASE_URL instead of failing
on an unusable environment name without breaking the ability to
pass a valid url in a string.

Among other things, this fixes rake db:fixtures:load on Heroku Cedar.

@MacksMind MacksMind Ensure DATABASE_URL is not ignored when database.yml isn't loaded
Currently specifying an environment name when DATABASE_URL is present
prevents a sucessful connection. Passing a string such as "production"
causes DATABASE_URL to be ignored because
ActiveRecord::Base.establish_connection only uses it if no name is
passed, but database.yml isn't loaded by the initializer if DATABASE_URL
is defined.

This change causes the resolver to use DATABASE_URL instead of failing
on an unusable environment name without breaking the ability to
pass a valid url in a string.
3a9e25c
Contributor
wuputah commented Jun 23, 2012

👍 cc/ @hone

Contributor

Awesome ! 👍

Member

@macksmind can you take a look at #7521 and tell me if this is still an issue?

Member

@macksmind I'm pretty sure that #7521 fixes your issue, and we haven't heard from you in months. I'm giving this a close, and if you can demonstrate that it's still a problem, we can re-open.

Contributor

@steveklabnik My use case was running rake db:fixtures:load on a new app at Heroku. That worked for me this morning, so I'm happy.

Contributor

@schneems Thanks!

Member

🤘 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment