https://github.com/tpope/rails-default-database
Make database.yml optional in Rails
https://github.com/tpope/rails-default-database
Last synced: about 1 year ago
JSON representation
Make database.yml optional in Rails
- Host: GitHub
- URL: https://github.com/tpope/rails-default-database
- Owner: tpope
- License: mit
- Created: 2011-01-04T15:38:27.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2021-05-27T17:10:33.000Z (about 5 years ago)
- Last Synced: 2025-04-14T07:55:00.327Z (about 1 year ago)
- Language: Ruby
- Homepage: http://rubygems.org/gems/rails-default-database
- Size: 19.5 KB
- Stars: 49
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: MIT-LICENSE
Awesome Lists containing this project
README
# Rails Default Database
Tired of `cp config/database.example.yml config/database.yml`? Me too.
That's why I wrote this Gem. Simply add this line to your Gemfile and
PostgreSQL, MySQL, or SQLite3 (depending on which of the 3 is in your
Gemfile) will be automatically configured with Rails defaults:
gem 'rails-default-database'
You can still override the defaults by creating `config/database.yml`.
Use `rake db:config` to create `config/database.yml` with the defaults
that would have been assumed.
The default database name is based on the name of the root directory of your
application. This can be overridden by setting
`config.database_name = 'foo_%s'` in `config/application.rb`, with `%s` being
a placeholder for the current environment name.
As in standard Rails, the `DATABASE_URL` environment variable takes
precedence when defined. However, in the test environment, Rails Default
Database will append `_test` to the database name (after stripping an optional
existing environment suffix), ensuring the development (or production!)
database is never clobbered. This enables storing your database configuration
in [`.env`](https://github.com/bkeepers/dotenv), if you so choose.
## License
Copyright (c) Tim Pope. MIT License.