Skip to content

Commit bb3da87

Browse files
committed
Draft of the release notes
1 parent 5345b04 commit bb3da87

File tree

2 files changed

+251
-2
lines changed

2 files changed

+251
-2
lines changed

guides/source/7_2_release_notes.md

Lines changed: 251 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ Ruby on Rails 7.2 Release Notes
55

66
Highlights in Rails 7.2:
77

8+
These release notes cover only the major changes. To learn about various bug
9+
fixes and changes, please refer to the changelogs or check out the [list of
10+
commits](https://github.com/rails/rails/commits/7-2-stable) in the main Rails
11+
repository on GitHub.
12+
813
--------------------------------------------------------------------------------
914

1015
Upgrading to Rails 7.2
@@ -21,6 +26,251 @@ guide.
2126
Major Features
2227
--------------
2328

29+
### Development Containers configuration for applications
30+
31+
A [development container](https://containers.dev/) (or dev container for short) allows you to use a container
32+
as a full-featured development environment.
33+
34+
Rails 7.2 adds the ability to generate a development container configuration for your application. This configuration
35+
includes a `.devcontainer` folder with a `Dockerfile`, a `docker-compose.yml` file, and a `devcontainer.json` file.
36+
37+
By default the dev container contains the following:
38+
39+
* A redis container for use with Kredis, Action Cable etc.
40+
* A database (SQLite, Postgres, MySQL or MariaDB)
41+
* A Headless chrome container for system tests
42+
* Active Storage configured to use the local disk and with preview features working
43+
44+
To generate a new application with a development container, you can run:
45+
46+
```bash
47+
rails new myapp --devcontainer
48+
```
49+
50+
For existing applications, a `devcontainer` command is now available:
51+
52+
```bash
53+
rails devcontainer
54+
```
55+
56+
For more information, see the [Getting Started with Dev Containers](https://edgeguides.rubyonrails.org/getting_started_with_devcontainer.html) guide.
57+
58+
### Add browser version guard by default
59+
60+
Rails now adds the ability to specify the browser versions that will be allowed to access all actions
61+
(or some, as limited by `only:` or `except:`).
62+
63+
Only browsers matched in the hash or named set passed to `versions:` will be blocked if they're below the versions
64+
specified.
65+
66+
This means that all other unknown browsers, as well as agents that aren't reporting a user-agent header, will be allowed access.
67+
68+
A browser that's blocked will by default be served the file in `public/406-unsupported-browser.html` with a HTTP status
69+
code of "406 Not Acceptable".
70+
71+
Examples:
72+
73+
```ruby
74+
class ApplicationController < ActionController::Base
75+
# Allow only browsers natively supporting webp images, web push, badges, import maps, CSS nesting + :has
76+
allow_browser versions: :modern
77+
end
78+
79+
class ApplicationController < ActionController::Base
80+
# All versions of Chrome and Opera will be allowed, but no versions of "internet explorer" (ie). Safari needs to be 16.4+ and Firefox 121+.
81+
allow_browser versions: { safari: 16.4, firefox: 121, ie: false }
82+
end
83+
84+
class MessagesController < ApplicationController
85+
# In addition to the browsers blocked by ApplicationController, also block Opera below 104 and Chrome below 119 for the show action.
86+
allow_browser versions: { opera: 104, chrome: 119 }, only: :show
87+
end
88+
```
89+
90+
For more information, see the [allow_browser](https://api.rubyonrails.org/classes/ActionController/AllowBrowser/ClassMethods.html#method-i-allow_browser)
91+
documentation.
92+
93+
### Make Ruby 3.1 the new minimum version
94+
95+
Until now, Rails only droped compatibility with older Rubies on new majors version.
96+
We are changing this policy because it causes us to keep compatibility with long
97+
unsupported versions of Ruby or to bump the Rails major version more often, and to
98+
drop multiple Ruby versions at once when we bump the major.
99+
100+
Now we are going to drop Ruby versions on minor versions, following the recommendation
101+
from th Ruby team at the time of the release.
102+
103+
For Rails 7.2, Ruby 3.1 is the new minimum version.
104+
105+
### Default Progressive Web Application (PWA) files
106+
107+
In preparation to better support creating PWA applications with Rails, we now generate default PWA files for manifest
108+
and service-worker that are served from `app/views/pwa` and can be dynamically rendered through ERB. Those files
109+
are mounted explicitly at the root with default routes in the generated routes file.
110+
111+
For more information, see the [pull request adding the feature](https://github.com/rails/rails/pull/50528).
112+
113+
### Add omakase RuboCop rules by default
114+
115+
Rails applications now come with [RuboCop](https://rubocop.org/) configured with a set of rules from [rubocop-rails-omakase](https://github.com/rails/rubocop-rails-omakase) by default.
116+
117+
Ruby is a beautifully expressive language that not only tolerates many different dialects, but celebrates their
118+
diversity. It was never meant as a language to be written exclusively in a single style across all libraries,
119+
frameworks, or applications. If you or your team has developed a particular house style that brings you joy,
120+
you should cherish that.
121+
122+
This collection of Rubocop styles is for those who haven't committed to any specific dialect already. Who would just
123+
like to have a reasonable starting point, and who will benefit from some default rules to at least start a consistent
124+
approach to Ruby styling.
125+
126+
These specific rules aren't right or wrong, but merely represent the idiosyncratic aesthetic sensibilities of Rails'
127+
creator. Use them whole, use them as a starting point, use them as inspiration, or however you see fit.
128+
129+
### Add GitHub CI workflow by default to new applications
130+
131+
Rails now adds a default GitHub CI workflow file to new applications. This will get especially newcomers off to a good
132+
start with automated scanning, linting, and testing. We find that a natural continuation for the modern age of what
133+
we've done since the start with unit tests.
134+
135+
It's of course true that GitHub Actions are a commercial cloud product for private repositories after you've used the
136+
free tokens. But given the relationship with GitHub and Rails, the overwhelming default nature of the platform for
137+
newcomers, and the value of teaching newcomers good CI habits, We find this to be an acceptable trade-off.
138+
139+
### Add Brakeman by default to new apps
140+
141+
[Brakeman](https://brakemanscanner.org/) is a great way to prevent common security vulnerabilities in Rails from going
142+
into production.
143+
144+
New application come with Brakeman installed and combined with the GitHub CI workflow, it will run automatically on
145+
every push.
146+
147+
### Set a new default for the Puma thread count
148+
149+
Rails changed the default number of threads in Puma from 5 to 3.
150+
151+
Due to the nature of well optimized Rails applications, with quick SQL queries and slow 3rd party calls running via jobs,
152+
Ruby spends most of its time waiting for the Global VM Lock (GVL) to release when the thread count is too high.
153+
154+
After careful consideration, investigation and based on battle tested experience from applications running in
155+
production, we decided that a default of 3 threads is a good balance between concurrency and performance.
156+
157+
You can follow a very detailed discussion about this change in [the issue](https://github.com/rails/rails/issues/50450).
158+
159+
### Prevent jobs from being scheduled within transactions
160+
161+
A common mistake with Active Job is to enqueue jobs from inside a transaction, causing them to potentially be picked
162+
and ran by another process, before the transaction is committed, which result in various errors.
163+
164+
```ruby
165+
Topic.transaction do
166+
topic = Topic.create
167+
168+
NewTopicNotificationJob.perform_later(topic)
169+
end
170+
```
171+
172+
Now Active Job will automatically defer the enqueuing to after the transaction is committed, and drop the job if the
173+
transaction is rolled back.
174+
175+
Various queue implementations can chose to disable this behavior, and users can disable it, or force it on a per job
176+
basis:
177+
178+
```ruby
179+
class NewTopicNotificationJob < ApplicationJob
180+
self.enqueue_after_transaction_commit = false
181+
end
182+
```
183+
184+
This is now possible due to a new feature that allows to register transaction callbacks outside of a record.
185+
186+
`ActiveRecord::Base.transaction` now yields an `ActiveRecord::Transaction` object, which allows to register callbacks
187+
on it.
188+
189+
```ruby
190+
Article.transaction do |transaction|
191+
article.update(published: true)
192+
193+
transaction.after_commit do
194+
PublishNotificationMailer.with(article: article).deliver_later
195+
end
196+
end
197+
```
198+
199+
`ActiveRecord::Base.current_transaction` was also added to allow to register callbacks on it.
200+
201+
```ruby
202+
Article.current_transaction.after_commit do
203+
PublishNotificationMailer.with(article: article).deliver_later
204+
end
205+
```
206+
207+
And finally, `ActiveRecord.after_all_transactions_commit` was added, for code that may run either inside or outside a
208+
transaction and need to perform works after the state changes have been properly persisted.
209+
210+
```ruby
211+
def publish_article(article)
212+
article.update(published: true)
213+
214+
ActiveRecord.after_all_transactions_commit do
215+
PublishNotificationMailer.with(article: article).deliver_later
216+
end
217+
end
218+
```
219+
220+
See the related pull requests for more information:
221+
222+
https://github.com/rails/rails/pull/51474
223+
https://github.com/rails/rails/pull/51426
224+
225+
### Enable YJIT by default if running Ruby 3.3+
226+
227+
YJIT in Ruby's JIT compiler that is available in CRuby since Ruby 3.1. It can provide significant performance
228+
improvements for Rails applications, ranging 15-25% latency improvements.
229+
230+
In Rails 7.2, YJIT is enabled by default if running Ruby 3.3 or newer.
231+
232+
You can disable YJIT by setting:
233+
234+
```ruby
235+
Rails.application.config.yjit = false
236+
```
237+
238+
### New design for the Rails guides
239+
240+
When Rails 7.0 landed in December 2021, it came with a fresh new homepage and a new boot screen. The design of the
241+
guides, however, has remained largely untouched since 2009 - a point which hasn’t gone unnoticed (we heard your feedback).
242+
243+
With all of the work right now going into removing complexity from the Rails framework and making the documentation
244+
consistent, clear, and up-to-date, it was time to tackle the design of the guides and make them equally modern, simple,
245+
and fresh.
246+
247+
We worked with UX designer [John Athayde](https://meticulous.com/) to take the look and feel of the homepage and
248+
transfer that over to the Rails Guide to make it clean, sleek, and up-to-date.
249+
250+
The layout will remain the same, but from today you will see the following changes reflected in the Guides:
251+
252+
* Cleaner, less busy design.
253+
* Fonts, color scheme, and logo more consistent with the home page.
254+
* Updated iconography.
255+
* Simplified navigation.
256+
* Sticky ‘Chapter’ navbar when scrolling.
257+
258+
See the [announcement blog post for some before/after images](https://rubyonrails.org/2024/3/20/rails-guides-get-a-facelift).
259+
260+
### Setup jemalloc in default Dockerfile to optimize memory allocation
261+
262+
[Ruby's use of malloc can create memory fragmentation problems, especially when using multiple threads](https://www.speedshop.co/2017/12/04/malloc-doubles-ruby-memory.html)
263+
like Puma does. Switching to an allocator that uses different patterns to avoid fragmentation can decrease memory usage
264+
by a substantial margin.
265+
266+
Rails 7.2 now includes jemalloc in the default Dockerfile to optimize memory allocation.
267+
268+
### Suggest puma-dev configuration in bin/setup
269+
270+
puma-dev is the golden path for developing multiple Rails applications locally, if you're not using Docker.
271+
272+
Rails now suggests how to get that setup for apps with bin/setup.
273+
24274
Railties
25275
--------
26276

@@ -64,7 +314,7 @@ Please refer to the [Changelog][railties] for detailed changes.
64314

65315
* System tests now use headless Chrome by default for new applications.
66316

67-
* Support the `BACKTRACE` environment variable to turn off backtrace cleaning in normal server runnings.
317+
* Support the `BACKTRACE` environment variable to turn off backtrace cleaning in normal server runnings.
68318
Previously, this was only available for the testing.
69319

70320
* Add default Progressive Web App (PWA) files for the manifest and service worker, served from `app/views/pwa`,

guides/source/documents.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@
335335
name: Version 7.2 - ?
336336
url: 7_2_release_notes.html
337337
description: Release notes for Rails 7.2.
338-
work_in_progress: true
339338
-
340339
name: Version 7.1 - October 2023
341340
url: 7_1_release_notes.html

0 commit comments

Comments
 (0)