Skip to main content

The Rails New Command

Published: August 11, 2020

This is part of The Annotated Guide to a New Rails App, a list of recommendations to make developing your Rails app more productive and joyful.

In this article, we are talking about the Rails “new” command.

When

The Rails “new” command is used to create a brand new Rails application. It creates a directory with the framework and all the boilerplate code installed.

Why

It takes a lot of files with a lot of code to have a working Rails project. Rather than make you create and write them all yourself, Rails has a command-line interface that will create them for you.

How

If you do not have the Rails gem already, install it with gem install rails.

If you already have the Rails gem, you can update it with gem update rails.

Make sure you are using the version of Rails you want to be using with rails --version. You can see the latest version of Rails on the website.

To create a new Rails project run: rails new projectname.

The Rails gem will create a new directory named projectname and create a new Rails project in that directory.

Alternatives

The Rails “new” command accepts a lot of options to change the default behavior. Many of them make a lot of my later recommendations unnecessary. I haven’t included them here for a couple of reasons.

First, I don’t know what they are.

But more importantly, I advocate for putting off decisions whenever possible. It’s easy to get caught in the trap of trying to figure out the exact right set of options to use to create your new application. I’d rather create my Rails app with the default settings and change things easily in the future when (and if!) the need arises.