You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+
classNewTopicNotificationJob < 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
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
+
24
274
Railties
25
275
--------
26
276
@@ -64,7 +314,7 @@ Please refer to the [Changelog][railties] for detailed changes.
64
314
65
315
* System tests now use headless Chrome by default for new applications.
66
316
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.
68
318
Previously, this was only available for the testing.
69
319
70
320
* Add default Progressive Web App (PWA) files for the manifest and service worker, served from `app/views/pwa`,
0 commit comments