Rails has these generators that we can use to customize every new app that we create based on our requirements.
Suppose, we want to create a new Rails app with Postgresql DB instead of the default sqlite3, then we can use the --database
alias.
rails new myapp --database=postgresql
rails new myapp -d=postgresql
Similarly, we could also use these generator options to remove something we don’t want.
For example, if we want to write our tests using RSpec
and do not want the unnecessary test
directory from getting created.
We could use the -T
or --skip-test
aliases.
rails new myapp -T
rails new myapp --skip-test
In Rails 6, the option webpacker got replaced with --javascript
to allow apps to with import-map
, es-build
, or webpacker
.
rails new myapp -j esbuild
rails new myapp --javascript esbuild
Rails will now allow --js
as a new alias along with -j
and --javascript
to customize apps with javascript.
So, if we need to create apps with esbuild
, webpacker
, or rollup
as our javascript choice, we should be able to use the new alias.
rails new myapp --js esbuild
rails new myapp --js webpack
rails new myapp --js rollup
We should also be able to use --skip-js
alias instead of --skip-javascript
to skip any javascript option altogether.
rails new myapp --skip-js esbuild
rails new myapp --skip-js webpack
rails new myapp --skip-js rollup
It is a minor enhancement, but it makes a lot more sense as we tend to associate JavaScript with js
alias more than j
intuitively.
Note: The enhancement is yet to be released in the official Rails version