Skip to content

Commit 5981999

Browse files
vipulnswardmorgoth
andauthored
Import TWIR 404 (#466)
* Add draft * Spacing * Spacing * Update _posts/2025-04-04-this-week-in-rails.markdown Co-authored-by: Wojciech Wnętrzak <[email protected]> --------- Co-authored-by: Wojciech Wnętrzak <[email protected]>
1 parent cb4bca1 commit 5981999

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
layout: post
3+
title: "must-understand, with_default_isolation_level, Rails World CFP and more!"
4+
categories: news
5+
author: vipulnsward
6+
og_image: assets/images/this-week-in-rails.png
7+
published: true
8+
date: 2025-04-04
9+
---
10+
11+
Hi, it's [Vipul](https://www.saeloun.com/team/vipul). Let's explore this week's changes in the Rails codebase.
12+
13+
[Last Week for Rails World 2025 Call for Papers](https://rubyonrails.org/2025/3/7/apply-to-speak-at-rails-world-2025)
14+
This is the last week for The CFP for Rails World 2025!
15+
16+
[Submit your talk until April 10th.](https://sessionize.com/rails-world-2025/)
17+
18+
[Add must-understand directive according to RFC 9111](https://github.com/rails/rails/pull/54833)
19+
The `must-understand` directive indicates that a cache must understand the semantics of the response status code, or discard the response. This directive is enforced to be used only with `no-store` to ensure proper cache behavior.
20+
21+
```ruby
22+
class ArticlesController < ApplicationController
23+
def show
24+
@article = Article.find(params[:id])
25+
if @article.special_format?
26+
must_understand
27+
render status: 203 # Non-Authoritative Information
28+
else
29+
fresh_when @article
30+
end
31+
end
32+
end
33+
```
34+
35+
[Use UNLINK for RedisCacheStore in ActiveSupport](https://github.com/rails/rails/pull/54861)
36+
The `RedisCacheStore` now uses Redis's `UNLINK` command instead of `DEL` for cache entry deletion, enabling asynchronous and non-blocking removal of keys, which enhances performance.
37+
38+
[Add `Cache#read_counter` and `Cache#write_counter`](https://github.com/rails/rails/pull/54855)
39+
This introduces 2 new methods on `Rails.cache`: `read_counter` and `write_counter`, to read values that are being incremented/decremented.
40+
41+
```ruby
42+
Rails.cache.write_counter("foo", 1)
43+
Rails.cache.read_counter("foo") # => 1
44+
Rails.cache.increment("foo")
45+
Rails.cache.read_counter("foo") # => 2
46+
```
47+
48+
[Change redirect status code in SessionsController#destroy template from 302 to 303](https://github.com/rails/rails/pull/54849)
49+
The new Authentication generator introduced in Rails 8.0, creates a `SessionsController` that returns a 302 Redirect response in its destroy action.
50+
With this change it will now issue a 303(See Other) status code instead of 302(Found) when redirecting after logout, to comply with the [9110 spec](https://www.rfc-editor.org/rfc/rfc9110#status.302)
51+
52+
[Include cookie name in length calculation](https://github.com/rails/rails/pull/54843)
53+
This change updates Rails to include the cookie name's length when validating that a cookie stays within the 4KB limit,
54+
aligning its behavior with browser standards.
55+
56+
[Introduce with_default_isolation_level in ActiveRecord](https://github.com/rails/rails/pull/54836)
57+
This change introduces the `with_default_isolation_level` method in ActiveRecord, allowing to set a default database isolation level for specific code blocks.
58+
This is particularly useful when migrating large applications to a new isolation level, as it enables enforcing the desired level in targeted areas, such as base controllers, facilitating smoother transitions and ensuring consistent transaction behavior.
59+
60+
```ruby
61+
class ApiV2Controller < ApplicationController
62+
around_action :set_isolation_level
63+
64+
def set_isolation_level
65+
Product.with_default_isolation_level(:read_committed) do
66+
yield
67+
end
68+
end
69+
end
70+
# forces all controllers that subclass from ApiV2Controller to start getting new isolation level
71+
```
72+
73+
[With postgres adapter, prepend `structure_load_flags` instead of appending them](https://github.com/rails/rails/pull/54813)
74+
When using postgres adapter and the `structure_load_flags` options, the extra flags were appended instead of prepended to the default ones, causing the `psql` command to ignore some of the extra flags.
75+
Now, the default arguments `args` are appended to the `extra_flags` instead of the opposite.
76+
77+
_You can view the whole list of changes [here](https://github.com/rails/rails/compare/@%7B2025-03-29%7D...main@%7B2025-04-04%7D)._
78+
_We had [15 contributors](https://contributors.rubyonrails.org/contributors/in-time-window/20250329-20250404) to the Rails codebase this past week!_
79+
80+
Until next time!
81+
82+
_[Subscribe](https://world.hey.com/this.week.in.rails) to get these updates mailed to you._

0 commit comments

Comments
 (0)