RailsDbConfigResolver
Resolves database configuration in the same way that rails does. This is useful when wanting to connect to rail's database without loading the rails environment or when wanting to use em-pg-client for a helper process in a rails app.
Values from ENV['DATABASE_URL']
and config/database.yml
are merged. ENV['DATABASE_URL']
trumps config/database.yml
.
By looking at the rails guide, I think the url field in database.yml
trumps both of them, but I'm not sure, so I left it out.
Installation
Add this line to your application's Gemfile:
gem 'rails_db_config_resolver'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rails_db_config_resolver
Usage
For now, check out spec/rails_db_config_resolver_spec.rb
.
Contributing
- Fork it ( https://github.com/cameron-martin/rails_db_config_resolver/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request