DEV Community

Cover image for Know the difference between `rails new` with flags
Shinji NAKAMATSU
Shinji NAKAMATSU

Posted on

Know the difference between `rails new` with flags

Whenever I do rails new, I always have to check the effect of --skip-xxx, so I created a repository.

What I made

In this repository, the code output from running rails new with the Rails version and flag combination can be referenced by git tags.

The name of the tag is in the form {Rails version}-{flag}.

For example, Rails 7.0.1 code output with --minimal can be referenced by the tag 7.0.1-minimal.

Currently, the supported Rails versions are as follows

  • 6.0.x
  • 6.1.x
  • 7.0.x

Usage

It may be obvious when you see it, but just in case, here is how to use it.

For example, in Rails 7.0.1, there is a flag called --api and you want to find out how specifying it changes the generated code.

Table in README.markdown(Following is an excerpt) to the --api flag line, click on the ๐Ÿ” at the 7.0.1 position to see the diff on GitHub.

flag 6.0.4.4 6.1.4.4 7.0.1
--api ๐Ÿ” ๐Ÿ” ๐Ÿ”

(Diff. display as of 2022-01-08)

image.png

From the above, we can see that specifying --api makes the following difference in the output results.

  • Gemfile ใซ sprockets-rails, importmap-rails, turbo-rails, stimulus-rails, jbuilder, ... (Omitted) ... is removed
  • Parent class of ApplicationController changes from ActionController::Base to ActionController::API.
  • Middleware configuration changes to the minimum required by adding config.api_only = true setting.
  • And so on...

You can also compare arbitrary Tags by writing your own URLs. For more information on how to compare tags on GitHub, please refer to the following document.

Oldest comments (0)