How To Configure Your “$ Rails New” Defaults
If you’ve used Ruby on Rails before, you’re probably familiar with the standard way of generating a new rails project:
$ rails new myAwesomeApp
However, did you know that you can add default options for your rails app? For example, if you want rails to skip test unit (if you’re using rspec instead), skip bundle install, and set your default database to PostgreSQL you can run:
$ rails new myAwesomeApp --skip-test-unit --skip-bundle -d postgresql
If you have specific defaults that you always use, here is a simple to configure the default rails command (“$ rails new myAwesomeApp”) to always include your options:
First, to view all the possible options for the rails new command, simply type this in your terminal:
$ rails new --help
Now, simple put in the defaults in your ~/.railsrc file, which you can open with text mate via the command line:
$ mate ~/.railsrc
My defaults are as follows:
--skip-bundle #skips bundle install on generating a new rails app --skip-test-unit #skips making the test unit folders (I use rspec) -d postgresql #defaults my development database to PostgreSQL instead of SQLite3
Now, whenever I run “$ rails new myAwesomeApp”, the generated rails project automatically skips over bundle, skips test unit, and sets my database to PostgreSQL!