This Week in Rails

August 16, 2024

Deferred routes drawing, connect route helper and more

Hi, Wojtek from this side. Let’s explore this week’s changes in the Rails codebase.

Defer route drawing
This change triggers the initial reload of routes either through middleware or when a url_helpers method is used. Previously, this was executed unconditionally on boot, which could slow down boot time unnecessarily for larger apps with lots of routes. Environments like production that have config.eager_load = true will continue to eagerly load routes on boot.

Add connect route helper
Defines a route that recognizes HTTP CONNECT (and GET) requests. More specifically this recognizes HTTP/1 protocol upgrade requests and HTTP/2 CONNECT requests with the protocol pseudo header.

Bulk insert fixtures on SQLite
Previously one insert command was executed for each fixture, now they are aggregated in a single bulk insert command.

Update PostgreSQL adapter extensions to include schema name
The schema dumper will now include the schema name in generated enable_extension statements if they differ from the current schema.

Add escape_html_entities option to JSON encoder
This allows for overriding the global configuration found at ActiveSupport.escape_html_entities_in_json for specific calls to to_json. This can be used from controllers in the following manner:

class MyController < ApplicationController
  def index
    render json: {hello: "world"}, escape_html_entities: false
  end
end

Remove racc gem dependency

ActionDispatch::Journey::Parser does not need to be generated by racc. This will open the possibility to optimize it in the future.

Support minitest 5.25+
Minitest 5.25 changed the signature of one of the internal methods that was used by Rails.

Enable query log tags by default on development env
This can be used to trace troublesome SQL statements back to the application code that generated these statements. It is also useful when using multiple databases because the query logs can identify which database is being used.

Fix returning type from encrypted attribute

Previously it always returned :text type.

Raise when using key which can’t respond to #to_sym in encrypted configuration

As is the case when trying to use an Integer or Float as a key, which is unsupported.

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

Until next time!

About This Week in Rails

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