This Week in Rails

July 22, 2022

Bugfixes, performance improvements and more!

Hi, this is Greg, bringing you the latest news from the Rails world.

Fix caching of missed translations
Using for the default value of a missing translation caused the cache store to return a different object when being fetched from the cache. This PR changes the default to an integer, which resolves the problem.

Add endless range example to the Active Record Querying guide
Beginless/endless ranges can be used to create less than/greater than conditions with Active Record, but that was an undocumented feature before this PR added it to the Rails Guides.

Prevent ActionDispatch::ServerTiming from overwriting existing header value
This change fixes the issue of ActionDispatch::ServerTiming overwriting instead of appending to the Server-Timing header.

Allow to use pre-defined variants for previews
This PR adds the ability to use pre-defined variants when calling preview or representation on an attachment. For instance:

class User < ActiveRecord::Base
  has_one_attached :file do |attachable|
    attachable.variant :thumb, resize_to_limit: [100, 100]

<%= image_tag user.file.representation(:thumb) %>

Speedup ActionView::OutputBuffer
Ruby 3.2 noticeably improved the performance of String#<< so by using a String instance instead of a String subclass there are performance gains.

Since last week, 17 people contributed to Rails. As usual, there are too many changes to cover them all, but you can check out all of them here. Until next time!

About This Week in Rails

Your weekly inside scoop of interesting commits, pull requests and more from Rails.