title: Why does my rails app ignore the env var DATABASE_URL at console startup?
body: <p><strong>tl;dr:</strong></p>
  
  <pre><code>$ export DATABASE_URL=postgres://user:pwd@localhost:5432/new_db
  $ RAILS_ENV=test bundle exec rails c
  [1] pry(main)&gt; ActiveRecord::Base.connection.current_database
  =&gt; "test"
  [2] pry(main)&gt; ActiveRecord::Base.establish_connection;nil
  =&gt; nil
  [3] pry(main)&gt; ActiveRecord::Base.connection.current_database
  =&gt; "new_db"
  [4] pry(main)&gt; # WTF ?!?
  </code></pre>
  
  <p><strong>Background</strong>: We are currently hosting several jobs to build, test and push to heroku our DEV and QA environments. As we were having the same test configuration in the database.yml file, we ended up with failing tests when both env where tested at the same time, so we decided to use two databases.</p>
  
  <p><strong>What we were trying</strong>: To achieved that (use several databases whith the same database.yml file), we decided to set to value of the DATABASE_URL environment variable to 'postgres://user:pwd@localhost:5432/new_db'.</p>
  
  <p><strong>What is the issue</strong>: The value of DATABASE_URL only seems to be used when we run establish_connection manually in a console. Oddly, running rake has effect on the right db (new_db).</p>
  
  <p>Rails version is 3.2.19</p>
  
  <p>Is there any way to override properly that environment variable ?</p>
  
  <p>Many thanks in advance !</p>