Wednesday, May 29, 2024

Rails 7.2 Beta 1: Better production defaults, Dev containers, new guides design, and more!

Posted by rafaelfranca

The train for the Rails 7.2 release is leaving the station and we’re excited to announce the first beta release of Rails 7.2! There has been close to 2,500 commits made by over 400 contributors since Rails 7.1, so this release is packed with new features and improvements.

Please help us test all this new stuff, so we can ensure a solid final release of Rails 7.2.

Better production defaults

Rails 7.2 comes with better productions defaults to help you build more efficient applications.

Starting with YJIT. YJIT is Ruby’s JIT compiler that is available in CRuby since Ruby 3.1. It can provide significant performance improvements for Rails applications, offering 15-25% latency improvements.

In Rails 7.2, YJIT is enabled by default if running Ruby 3.3 or newer.

After careful consideration, investigation, and based on battle-tested experience from applications running in production, we decided to change the default number of threads in Puma from 5 to 3. This change is to improve latency (request response time) by reducing the time Ruby spends waiting for the Global VM Lock (GVL) to release when the thread count is too high.

And the default Dockerfile generated by Rails now includes jemalloc to optimize memory allocation.

https://guides.rubyonrails.org/7_2_release_notes.html

Development containers configuration for applications

A development container (or dev container for short) allows you to use a container as a full-featured development environment.

Rails 7.2 adds the ability to generate a development container configuration for your application. This configuration includes a .devcontainer folder with a Dockerfile, a docker-compose.yml file, and a devcontainer.json file.

By default, the dev container contains the following:

  • A Redis container for use with Kredis, Action Cable, etc.
  • A database (SQLite, Postgres, MySQL or MariaDB)
  • A Headless Chrome container for system tests
  • Active Storage configured to use the local disk and with preview features working

To generate a new application with a development container, you can run:

rails new myapp --devcontainer

For existing applications, a devcontainer command is now available:

rails devcontainer

For more information, see the Getting Started with Dev Containers guide.

New design for the Rails guides

When Rails 7.0 landed in December 2021, it came with a fresh new homepage and a new boot screen. The design of the guides, however, has remained largely untouched since 2009 - a point which hasn’t gone unnoticed (we heard your feedback).

With all of the work right now going into removing complexity from the Rails framework and making the documentation consistent, clear, and up-to-date, it was time to tackle the design of the guides and make them equally modern, simple, and fresh.

We worked with UX designer John Athayde to take the look and feel of the homepage and transfer that over to the Rails guides to make them clean, sleek, and up-to-date.

The layout will remain the same, but from today you will see the following changes reflected in the guides:

  • Cleaner, less busy design.
  • Fonts, color scheme, and logo more consistent with the home page.
  • Updated iconography.
  • Simplified navigation.
  • Sticky “Chapters” navbar when scrolling.

See the announcement blog post for some before/after images.

Other improvements

Rails 7.2 also includes many other improvements and new features. Here are a few highlights:

  • Add browser version guard by default.
  • Make Ruby 3.1 the new minimum version.
  • Default Progressive Web Application (PWA) files.
  • Add omakase RuboCop rules by default.
  • Add GitHub CI workflow by default to new applications.
  • Add Brakeman by default to new applications.
  • Prevent jobs from being scheduled within transactions.
  • Per transaction commit and rollback callbacks.
  • Suggest puma-dev configuration in bin/setup.

Please check the Rails 7.2 release notes for more details.

Wrap up

Final release of Rails 7.2 is expected in a few weeks. In the meantime, please give a try to Rails 7.2.0.beta1, and let us know what you think.