Ruby on Rails 7 rejiggers JavaScript support

Now available in a production release, Rails 7 removes the requirements for Node.js and Webpack, while supporting NPM and ES module imports.

Ruby on Rails 7 rejiggers JavaScript support

Ruby on Rails 7, the latest version of the web application framework, is now available as a production release. The update embraces a full-stack approach to web development with support for JavaScript advancements.

Released December 15, Rails 7 leverages browser support for the ECMAScript 6 JavaScript standard and ECMAScript modules, wide adoption of HTTP/2, and the import maps standard for importing JavaScript modules. It gives developers a “no-Node” approach to front-end development while still providing access to NPM packages and modern JavaScript. Rails 7 replaces TurboLinks and Rails UJS with Hotwire’s Turbo and Stimulus on the front end.

Most Rails applications will not require Node.js, given the new defaults. Developers can use the JavaScript bundler they prefer, as Webpack is no longer required. The same approach has been taken with CSS bundlers that rely on Node; Rails 7 files require only a compiled application.css file. Bundlers such as Tailwind or Bootstrap can be used.

Rails 7.0 guides can be found at Rails 7.0 release notes are also available at the project website. Other improvements in Ruby on Rails 7:

  • Encrypted attributes have been added to Active Record, enabling applications to offer at-work encryption in addition to traditional at-rest and in-transit coverage. An additional security layer is provided through this improvement.
  • With asynchronous query loading, two unrelated queries can be run concurrently via a controller action.
  • The Zeitwerk code loader replaces the const_missing approach.
  • The Spring application preloader is no longer on by default, as faster computers have made it unnecessary except for the largest applications.

Copyright © 2021 IDG Communications, Inc.

How to choose a low-code development platform