`ActiveRecord::Base.configurations[config_environment]` is needed for `db:create` tasks. Before running that task, ActiveRecord isn't connected to the database (since it doesn't exist yet), so this hash contains the database config.

But this is great, I now saw that `ActiveRecord:Base.configurations` is set only when reading the config from a file, so it doesn't seem it would work otherwise, without your fix.