If Rails is not defined, check ENV["RAILS_ENV"] and ENV["RACK_ENV"].

This fixes a regression introduced by 6cc03675d30b58e28f585720dad14e947a57ff5b.

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.
Merge pull request #17305 from ziggythehamster/activerecord-connectionhandling-RAILS_ENV-without-rails

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