惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
J
Java Code Geeks
量子位
腾讯CDC
C
Check Point Blog
小众软件
小众软件
IT之家
IT之家
I
InfoQ
Hugging Face - Blog
Hugging Face - Blog
Stack Overflow Blog
Stack Overflow Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
博客园_首页
S
SegmentFault 最新的问题
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
Martin Fowler
Martin Fowler

Ruby on Rails: Compress the complexity of modern web apps

Safer to_i coercion, custom to_fs formats, and more! This Week in Rails: May 16, 2026 This Week in Rails: May 8, 2026 This Week in Rails: May 1, 2026 Active Record gets better every week Great big Rails World 2026 update: CFP, Corporate Support tickets, workshops Query command for database queries and more Explicit query: and body: kwargs for integration tests and more! Speedup ActiveRecord::LogSubscriber#sql_color and more! This Week in Rails: March 27, 2026 Rails Versions 8.0.5 and 8.1.3 have been released! Rails Versions 7.2.3.1, 8.0.4.1, and 8.1.2.1 have been released! This Week in Rails: March 20, 2026 Validate URI scheme in Action Text and more This Week in Rails: March 6, 2026 Planning Center is the newest Rails Foundation Contributing member Action Text gets Markdown conversion, editor links in devcontainers, and more! BARRA seeks Rails developer Joe Agliozzo is looking for a Rails developer The rise of lighttpd as the alternative web server When longer is better and more is more Snowdevil: First e-tailer on Rails Natural selection for frameworks in Ruby vs Java Address book tutorial in Portuguese Becoming a better programmer with Rails 10 Things Every Java Programmer Should Know About Ruby Really Getting Started in Rails Off the Treadmill, Onto the Rails Rails 0.9.5: A world of fixes and tweaks Rich clients with Rails and XUL
New database sharding methods, improved Active Record Mig...
David Heinemeier Hansson · 2024-06-21 · via Ruby on Rails: Compress the complexity of modern web apps

Friday, June 21, 2024
Posted by vipulnsward

Hey everyone, Happy Friday! Vipul here with the latest updates for This Week in Rails. Let’s dive in.

Improved Active Record Migration documentation
The Rails Foundation documentation team continues on improving different areas of the Guides. This Pull Request updates the Active Record Migration documentation to receive various additions, improvements and more.

Add .shard_keys, .sharded?, & .connected_to_all_shards methods to ActiveRecord::Base
This change adds .shard_keys, .sharded?, & .connected_to_all_shards methods to start returning sharding information for a model.

class ShardedBase < ActiveRecord::Base
  self.abstract_class = true

  connects_to shards: {
    shard_one: { writing: :shard_one },
    shard_two: { writing: :shard_two }
  }
end

class ShardedModel < ShardedBase
end

ShardedModel.shard_keys => [:shard_one, :shard_two]
ShardedModel.sharded? => true
ShardedBase.connected_to_all_shards { ShardedModel.current_shard } => [:shard_one, :shard_two]    

Expire caching when a download fail while proxying in Active Storage
The Proxy controllers in Active Storage set the caching headers early before streaming. In some instances, it was possible for the file download to fail before we send the first byte to the client. In those instances, this change would invalidate the cache and return a better response status before closing the stream.

Lazily generate assertion failure messages
Minitest supports passing the failure message as a callable, which allow us to defer generating failure messages. Some of these failure messages can be a bit costly to generate, particularly when inspecting very large objects or when accessing the AST of procs. This change, now defers the generation of the failure message by passing it in a callable instead.

Make “rails g scaffold” with no field produce RuboCop compliant code
When there are no fields and we use rails g scaffold, the generated code is not RuboCop compliant.

This change makes it compliant by:

  • Omitting a blank line in migration prior to “t.timestamps”.
  • Omitting leading and trailing spaces in empty hashes in create and update controller and api functional tests.

Fix alias_attribute to ignore methods defined in parent classes
When defining regular attributes, inherited methods aren’t overridden. However when defining aliased attributes, inherited methods aren’t considered. This change fixes alias_attribute to properly ignore methods defined in parent classes.

You can view the whole list of changes here.
We had 26 contributors to the Rails codebase this past week!

Until next time!

Subscribe to get these updates mailed to you.