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
Newly generated applications have this guard set in `ApplicationController`.
106
+
107
+
For more information, see the [allow_browser](https://api.rubyonrails.org/classes/ActionController/AllowBrowser/ClassMethods.html#method-i-allow_browser)
108
+
documentation.
109
+
110
+
### Make Ruby 3.1 the new minimum version
111
+
112
+
Until now, Rails only dropped compatibility with older Rubies on new majors version.
113
+
We are changing this policy because it causes us to keep compatibility with long
114
+
unsupported versions of Ruby or to bump the Rails major version more often, and to
115
+
drop multiple Ruby versions at once when we bump the major.
116
+
117
+
We will now drop Ruby versions that are end-of-life on minor Rails versions at the time of the release.
118
+
119
+
For Rails 7.2, Ruby 3.1 is the new minimum version.
120
+
121
+
### Default Progressive Web Application (PWA) files
122
+
123
+
In preparation to better supporting the creation of PWA applications with Rails, we now generate default PWA files for the manifest
124
+
and service worker, which are served from `app/views/pwa` and can be dynamically rendered through ERB. Those files
125
+
are mounted explicitly at the root with default routes in the generated routes file.
126
+
127
+
For more information, see the [pull request adding the feature](https://github.com/rails/rails/pull/50528).
128
+
129
+
### Add omakase RuboCop rules by default
130
+
131
+
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.
132
+
133
+
Ruby is a beautifully expressive language that not only tolerates many different dialects, but celebrates their
134
+
diversity. It was never meant as a language to be written exclusively in a single style across all libraries,
135
+
frameworks, or applications. If you or your team has developed a particular house style that brings you joy,
136
+
you should cherish that.
137
+
138
+
This collection of RuboCop styles is for those who haven't committed to any specific dialect already. Who would just
139
+
like to have a reasonable starting point, and who will benefit from some default rules to at least start a consistent
140
+
approach to Ruby styling.
141
+
142
+
These specific rules aren't right or wrong, but merely represent the idiosyncratic aesthetic sensibilities of Rails'
143
+
creator. Use them whole, use them as a starting point, use them as inspiration, or however you see fit.
144
+
145
+
### Add GitHub CI workflow by default to new applications
146
+
147
+
Rails now adds a default GitHub CI workflow file to new applications. This will get especially newcomers off to a good
148
+
start with automated scanning, linting, and testing. We find that a natural continuation for the modern age of what
149
+
we've done since the start with unit tests.
150
+
151
+
It's of course true that GitHub Actions are a commercial cloud product for private repositories after you've used the
152
+
free tokens. But given the relationship between GitHub and Rails, the overwhelming default nature of the platform for
153
+
newcomers, and the value of teaching newcomers good CI habits, we find this to be an acceptable trade-off.
154
+
155
+
### Add Brakeman by default to new applications
156
+
157
+
[Brakeman](https://brakemanscanner.org/) is a great way to prevent common security vulnerabilities in Rails from going
158
+
into production.
159
+
160
+
New applications come with Brakeman installed and combined with the GitHub CI workflow, it will run automatically on
161
+
every push.
162
+
163
+
### Set a new default for the Puma thread count
164
+
165
+
Rails changed the default number of threads in Puma from 5 to 3.
166
+
167
+
Due to the nature of well-optimized Rails applications, with quick SQL queries and slow 3rd-party calls running via jobs,
168
+
Ruby can spend a significant amount of time waiting for the Global VM Lock (GVL) to release when the thread count is too
169
+
high, which is hurting latency (request response time).
170
+
171
+
After careful consideration, investigation, and based on battle-tested experience from applications running in
172
+
production, we decided that a default of 3 threads is a good balance between concurrency and performance.
173
+
174
+
You can follow a very detailed discussion about this change in [the issue](https://github.com/rails/rails/issues/50450).
175
+
176
+
### Prevent jobs from being scheduled within transactions
177
+
178
+
A common mistake with Active Job is to enqueue jobs from inside a transaction, causing them to potentially be picked
179
+
and ran by another process, before the transaction is committed, which result in various errors.
180
+
181
+
```ruby
182
+
Topic.transaction do
183
+
topic =Topic.create
184
+
185
+
NewTopicNotificationJob.perform_later(topic)
186
+
end
187
+
```
188
+
189
+
Now Active Job will automatically defer the enqueuing to after the transaction is committed, and drop the job if the
190
+
transaction is rolled back.
191
+
192
+
Various queue implementations can chose to disable this behavior, and users can disable it, or force it on a per job
193
+
basis:
194
+
195
+
```ruby
196
+
classNewTopicNotificationJob < ApplicationJob
197
+
self.enqueue_after_transaction_commit =false
198
+
end
199
+
```
200
+
201
+
### Per transaction commit and rollback callbacks
202
+
203
+
This is now possible due to a new feature that allows registering transaction callbacks outside of a record.
204
+
205
+
`ActiveRecord::Base.transaction` now yields an `ActiveRecord::Transaction` object, which allows registering callbacks
See [#51474](https://github.com/rails/rails/pull/51474) and [#51426](https://github.com/rails/rails/pull/51426) for more information:
240
+
241
+
### Enable YJIT by default if running Ruby 3.3+
242
+
243
+
YJIT is Ruby's JIT compiler that is available in CRuby since Ruby 3.1. It can provide significant performance
244
+
improvements for Rails applications, offering 15-25% latency improvements.
245
+
246
+
In Rails 7.2, YJIT is enabled by default if running Ruby 3.3 or newer.
247
+
248
+
You can disable YJIT by setting:
249
+
250
+
```ruby
251
+
Rails.application.config.yjit =false
252
+
```
253
+
254
+
### New design for the Rails guides
255
+
256
+
When Rails 7.0 landed in December 2021, it came with a fresh new homepage and a new boot screen. The design of the
257
+
guides, however, has remained largely untouched since 2009 - a point which hasn’t gone unnoticed (we heard your feedback).
258
+
259
+
With all of the work right now going into removing complexity from the Rails framework and making the documentation
260
+
consistent, clear, and up-to-date, it was time to tackle the design of the guides and make them equally modern, simple,
261
+
and fresh.
262
+
263
+
We worked with UX designer [John Athayde](https://meticulous.com/) to take the look and feel of the homepage and
264
+
transfer that over to the Rails guides to make them clean, sleek, and up-to-date.
265
+
266
+
The layout will remain the same, but from today you will see the following changes reflected in the guides:
267
+
268
+
* Cleaner, less busy design.
269
+
* Fonts, color scheme, and logo more consistent with the home page.
270
+
* Updated iconography.
271
+
* Simplified navigation.
272
+
* Sticky "Chapters" navbar when scrolling.
273
+
274
+
See the [announcement blog post for some before/after images](https://rubyonrails.org/2024/3/20/rails-guides-get-a-facelift).
275
+
276
+
### Setup jemalloc in default Dockerfile to optimize memory allocation
277
+
278
+
[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)
279
+
like Puma does. Switching to an allocator that uses different patterns to avoid fragmentation can decrease memory usage
280
+
by a substantial margin.
281
+
282
+
Rails 7.2 now includes [jemalloc](https://jemalloc.net/) in the default Dockerfile to optimize memory allocation.
283
+
284
+
### Suggest puma-dev configuration in bin/setup
285
+
286
+
[Puma-dev](https://github.com/puma/puma-dev) is the golden path for developing multiple Rails applications locally, if you're not using Docker.
287
+
288
+
Rails now suggests how to get that setup in a new comment you'll find in `bin/setup`.
289
+
24
290
Railties
25
291
--------
26
292
@@ -36,21 +302,21 @@ Please refer to the [Changelog][railties] for detailed changes.
0 commit comments