Michael Anhari

Configuring your rails new command with a railsrc file

A top-down view of a keyboard and mouse

The rails new command has a lot of optional flags that you can pass it.

  • --skip-test to skip test files
  • --database=postgresql to define a database to use (in this case Postgres)
  • --skip-jbuilder to skip jbuilder, Rails's default answer for building JSON
  • --skip-sprockets you get the idea...

There's also a new --minimal flag that skips a lot of the stuff Rails brings along for the ride that you might not need (ActionCable, ActionMailer, etc.).

Configuring with a railsrc file

You can configure your rails new command to always include the same flags if you find yourself reaching them for them often. Start by creating a new .railsrc file in your home directory.

touch ~/.railsrc

In there, you can add whatever flags you like separated by new lines.

My railsrc file only contains --database=postgresql because I always want to use the Rails default stack with postgres. I am thinking about skipping sprockets at some point though.

Newsletter

I'm working on sending out a weekly newsletter. I'll make it as easy as possible to unsubscribe at any time.