The good news is Rails 6 is officially out and there are some changes and deprecations are shipped with it.

Let’s walk through the notable changes shipped in the Railties module.

  • Added an explicit option --using or -u for specifying the server for the rails server command

    1. Deprecated passing Rack server name as a regular argument to rails server
    2. Earlier we used to do it without specifying any option like rails s app_server_name.
  • Added ability to see the output of rails routes in expanded format.

    1. When using rails routes with small terminal viewport or complicated routes it can be very difficult to understand where a specific element is, especially when using header. psql had the same issue, that’s why they created “expanded mode” long time ago that you can switch using \x or by starting psql with
    2. Rails 6 has also added a similar option to view routes in a better way using --expanded option.
  • Added a command db:system:change --to=db_adapter_name to change the database of the application.

    • It’s common to create a new Rails app without specifying the database system upfront. That means you’ll get the SQLite system by default, which is great until you actually have to deploy in production. Then you usually want to swap SQLite out with something else, like MySQL or PostgreSQL. Doing so is too much of a hassle today.
    • I’d, therefore, like to see that we add a command that makes this easy. Running rails db:change –to=postgresql should overwrite config/database.yml with the database.yml config that already available in Railties for when a new app is started with –database=postgresql. It should also replace the gem “sqlite” line in the Gemfile with the PostgreSQL line.
    • The change command copies a template `config/database.yml` with the target database adapter into your app, and replaces your database gem with the target database gem using gsub command.
  • Add rails test:channels command to test only Action Cable channels.

  • Make Webpacker the default JavaScript compiler for Rails 6. This is the promising change and a lot has changed with this commit.

Below are the major changes shipped with this:

    1. Webpacker gem is installed by default and webpacker:install is run by the Rails application generator.
    2. ActionCable channel generators will create ES6 stubs over CoffeeScript.
    3. ActiveStorage, ActionCable, Turbolinks, and Rails-UJS is loaded by a new application.js pack in app/javascript by default (unless any of the frameworks have been opted-out)
    4. ActiveStorage, ActionCable, Turbolinks, and Rails-UJS npm modules are automatically listed as dependencies in the default package.json.
    5. All the JavaScript-related auxiliaries for Sprockets, like compression and uglifying, is no longer configured or included by default.
    6. No JavaScript stubs will be created by default when using the scaffold generators anymore.
  • Add multiple database support for rails db:migrate:status command.

  • Add support for multi environment credentials.

If one wants to use staging encrypted credentials use below command

rails credentials:edit --environment staging

This will create files config/credentials/staging.yml.enc and config/credentials/staging.key

When calling Rails.application.credentials in staging environment, it takes precedence over default config/credentials.yml.enc

Default paths can be overwritten by setting config.credentials.content_path and config.credentials.key_path. It is worth to note that the change is backward compatible.

Read Also: Notable ActiveRecord Changes In Rails 6 – Part 3

That’s all for now and stay tuned for more features and changes added in Rails 6 in upcoming blogs!!

At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.

We also specialize in Python, RPA, AI, Django, JavaScript and ReactJS.

Consulting is free – let us help you grow!