If Rails is not defined, check ENV["RAILS_ENV"] and ENV["RACK_ENV"] in ActiveRecord::ConnectionHandling

This fixes a regression introduced by 6cc0367.

ActiveRecord, if used without Rails, always checks the "default_env" environment. This would be OK, except that Sinatra also supports environments, and it runs with {RACK|RAILS}_ENV=production. This patch adds a fallback to RAILS_ENV and RACK_ENV (and ultimately default_env) if Rails.env doesn't exist.

Feedback requested on the tests, because I feel like there may need to be some more work there.

Also, this can probably cleanly apply against 4.1's stable branch.

Output of `rake test:sqlite3`:

```
Finished in 31.919725s, 132.6766 runs/s, 365.8866 assertions/s.

4235 runs, 11679 assertions, 0 failures, 0 errors, 2 skips

You have skipped tests. Run with --verbose for details.
```
So I was apparently not reading the [guide](http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#write-your-code) carefully.

The correction on `a=b` is still valid though (as it was: `"adapter"=>"postgresql"`). Sorry for such confusion.