On December 15, 2021 Ruby on Rails released version 7.0.0 of its web application framework. However, this came out earlier than I anticipated, so I have re-prioritized everything at Stateless Code to get the new Getting Started With Rails 7 series published as quickly as possible.
Now is the Time to Learn Ruby on Rails
In our Why Stateless Code? series I have a video on why you should use Ruby on Rails in the 2020s. I made the video when Rails 6.1 was the current version and some of the Rails 7 improvements were just coming out. The new changes in Ruby on Rails 7 make the development experience even better than it was before. Here are a few of the new features and improvements:
No Node dependency by default
Yes, you read that correctly. When you create a new application with Ruby on Rails 7, you no longer need to have NodeJS or Yarn installed on your system. As a result, you’ll notice that RailsUJS and Turbolinks are no longer the defaults for new applications. Instead, your new applications will include the Hotwire suite of Stimulus and Turbo. Of course, you can still use other front-end frameworks with Rails, but Hotwire provides a simpler way to solve most of your front-end use cases.
The new default uses import maps so that you can take advantages of the latest advances in modern web browsers. You can choose to include your JavaScript from a CDN (Content Delivery Network) to efficiently serve a pre-compiled distribution of the libraries you need. If you prefer, you can download the distributions and serve them out of the vendor/javascript
directory in your app.
Other notable improvements in Rails 7
Even though the biggest and most obvious changes in Ruby on Rails 7 related to front-end JavaScript integration, the project has made other improvements to increase programmer happiness. Many of these changes are modest, but they continue to simplify the complexities of web development. This lets you can focus on delivering value to your users. Here are a few more highlights:
- Skinny default Gemfile.lock. For a non-Windows Rails app, there are only nine uncommented entries in your Gemfile for production. (The other five only apply to development and/or test). Eliminating webpacker reduces the time and effort to create a new project.
- ActionController::Live#send_stream makes it easier to broadcast live changes to your users. In his Rails 7 demo video, David Heinemeier Hansson shows how easy it is to update the post view when comments change.
One response to “Ruby on Rails 7 is Out!”
[…] Ruby on Rails 7 is out! This is the 1st video in the Getting Started with Rails 7 series. In this video Mike provides an introduction and overview of Ruby on Rails, installs Rails 7 (and temporarily disables Node to show it’s no longer a default dependency), creates the example blog project, explores the directory of the created project, and starts up the Rails server. We cross-posted this video to our Setup and Configuration playlist. […]