DEV Community

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

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.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay