Rake tasks to help keep your production configurations out of the source control.
- To install you can either:
- Add
gem exemplifyto your Gemfile, and runbundle install, if you are using Rails 3 or later - Use lite version, simply copying exemplify rake task to your
lib/tasks/directory
-
For every configuration file in your
config/directory containing any secure information (likeconfig/database.yml) prepare template file with.exampleextension (e.g.config/database.yml.example), it could look something like this:# Example database configuration development: adapter: mysql2 encoding: utf8 database: INSERT_DATABASE_HERE pool: 5 timeout: 5000 username: INSERT_USERNAME_HERE password: INSERT_PASSWORD_HERE reconnect: true
-
Commit this file into your repository and ignore original files from the source control (e.g.
echo config/database.yml >> .gitignore) -
Remove original files from the source control:
git rm --cached config/database.yml- this will make sure the file is not present in repository, still keeping it locally. Do not forget to clear any sensitive information from git history -
Run
rake exemplify:FILENAMEto copy template contents into the file, like this:rake exemplify:config/database.yml
ProTips™:
-
Run
rake exemplify:allto copy all files at once, or userake -Tto see what example files you have prepared -
You can include additional rake logic for specific example files (so it will run right before exemplify task) like so:
file 'config/database.yml.example' do # Something happens here end