Use AR::Base.connection instead of database_configuration

Sometimes the `database.yml` configuration isn't avaliable for a given environment. 
For example heroku uses a environment variable called DATABASE_URL, instead of `production: ...` in `database.yml`. This PR changes the occurrences of `Rails.configuration.database_configuration` to `ActiveRecord::Base.connection`.

Closes #1579