How To Configure Your “$ Rails New” Defaults

7 Aug

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!

Advertisements

One Response to “How To Configure Your “$ Rails New” Defaults”

  1. austinwang August 10, 2012 at 12:02 am #

    Thanks natasha!! great post!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s