Ruby on Rails - September 2024
Ruby on Rails - September 2024 by Sajjad Umar

Ruby on Rails - September 2024

Welcome to the September 2024 edition of Ruby on Rails Monthly, this is Sajjad Umar your own Desi Developer. I have a piece of exciting news to share!

My book “Ruby on Rails for Agile Web Development“ is live!

Ruby on Rails for Agile Web Development is a Hands-on Guide to Building Dynamic and Efficient Web Applications. I have worked on this project with AVA™ - An Orange Education Label for over a year. I have dedicated countless hours to making it a reality and have done my utmost to create original and valuable content for readers.

This book is designed for beginners and seasoned professionals looking to delve into the intricacies of Agile Web Development with Ruby on Rails.

Get your copy here:

Orange AVA: https://orangeava.com/products/ruby-on-rails-for-agile-web-development

Amazon International: https://a.co/d/bXqyBCB

With that being said let’s jump right in with all the updates from Ruby on Rails world.

New Docs PRs for Review

Two new RRs for documentation are open for review:

EncryptedConfiguration: Raise when using a key that can't respond to #to_sym

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

This replaces the following less-friendly error:

With a more helpful error message:

Read all the details here.

Deferred route drawing to the first request, or when url_helpers called

The initial reload of routes is now triggered either via middleware or when a method is invoked. Previously, this process occurred unconditionally during boot, which could unnecessarily slow down the startup time in larger applications with many routes. In environments like production, where , routes will still be eagerly loaded at boot time.

Read all the details here.

Added route helper for WebSockets

Rails did not have a nice route helper for and WebSockets.

Previously you'd need to write something like this:

With this change, we can write:

Read all the details here.

EncryptedAttributeType#type now returns cast_type's type

This Pull Request changes two things:

  • it delegates method to actual instead of using one from

  • it changes class from which is inherited to a more generic .

Read all the details here.

Enabled 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.

Read all the details here.

ActiveRecord: Bulk insert fixtures on SQLite

SQLite supports bulk inserts, but one insert was created for each fixture. This PR makes it behave like the other adapters, creating a single bulk insert per fixture table and making tests with SQLite considerably faster.

Before:

After:

Read all the details here.

Supported minitest 5.25+

Minitest 5.25+ has a new API for with_info_handler that accepts an additional argument. Rails now supports all versions of minitest 5.

Read all the details here.

Updated PostgreSQLAdapter#extensions to include schema name

This allows the schema dumper's generated enable_extension statements to include the schema name, if different from .

Read all the details here.

ActionDispatch::Journey::Parser - Removed RACC

This Pull Request changes ActionDispatch::Journey::Parser to not be generated by racc.

Read all the details here.

Added escape_html_entities option to JSON encoder

This Pull Request changes JSON encoding code to accept an optional flag for whether or not to escape entities (). If not supplied, the existing global configuration flag will be used instead.

With this change, you can do as follows:

Read all the details here.

Allowed use of alternative database interfaces

Currently running rails is hardcoded to use the default interface for the given database (e.g. for ).

This PR allows the use of alternative interfaces by specifying the key in the database configuration.

Read all the details here.

Inferred default :inverse_of option for delegated_type

Before this commit, delegated types were unable to infer their inverse associations, so saving records built with the generated # methods weren't written to all the necessary places. For example:

When using delegated types, we can now infer the option for the association.

Read all the details here.

Encryption casting with encrypts before serialize

This PR ensures encrypted binary data is properly handled in PostgreSQL.

Read all the details here.

Supported dumping PostgreSQL inheritance & partitioning options to schema.rb

provides an options: key that allows you to append options to your table definition. One of the things you can do this way with 10+ uses native partitioning to declare partitioning definitions:

Adding this to a migration and running it will properly create the partitioned table in development, but the dumped schema will not persist the specified partitioning options. Therefore, if you run your test suite which loads from , your test database's table won't be properly partitioned.

This PR extends the adapter's schema statements so that it can dump this partitioning definition as defined in the relevant system tables.

Read all the details here.

Added store_if_blank option to has_rich_text

This PR introduces a . It defaults to true(the current behavior); if you pass false, AT won't create records when saving with a blank value.

Read all the details here.

SQLite non-GVL-blocking, fair retry interval busy handler

This PR improves SQLite connection handling for timeouts, by avoiding Ruby's Global Variable Lock (GVL) it can reduce SQLite3::BusyException errors and latency.

Read all the details here.

Fixed Devcontainer generator with --dev option path error

This Pull request moves the definition to module rather than adding it to in AppGenerator definition. It also creates a constant in , so that it can be used consistently in tests.

Read all the details here.

Striped encrypted file contents

This Pull Request strips the content file as well after reading to make sure it can be decrypted successfully.

Read all the details here.

Added support for SQLite3 full-text-search and other virtual tables

Rails now support SQLite3 full-text search and other virtual tables. Previously, adding SQLite3 virtual tables would cause issues with , but with this update, virtual tables can now be safely added using .

Read all the details here.

Supported custom environments on bin/rails credentials:diff

This Pull Request changes the way the environment is looked up. In addition to the current lookup in the available environments, it adds a fallback and it returns the name of the file in the provided path.

Read all the details here.

Rails 8 - Solid Cache is the new default caching backend

Solid Cache will be the new default caching backend for production deployments out of the box in Rails 8. We're also going to add Solid Queue by default, and both solid options will be bundled behind the same flag.

Read all the details here.

Rails 8 - Configured Solid Queue alongside Solid Cache by default

Solid Queue will be the new default DB-based queuing backend for Active Job out of the box in Rails 8.

Read all the details here.

Rails 8 - Added Solid Cable

Solid Cable is a database-backed Action Cable adapter that keeps messages in a table and continously polls for updates. This makes it possible to drop the common dependency on Redis, if it isn't needed for any other purpose. Despite polling, the performance of Solid Cable is comparable to Redis in most situations. And in all circumstances, it makes it easier to deploy Rails when Redis is no longer a required dependency for Action Cable functionality.

Solid Cable is the last piece before we can fully claim that Rails 8 only requires a database as a dependency to get access to all frameworks and functionality.

Read all the details here.

Updated Active Record Associations Guide

Updated the Active Record Association Documentation.

Read all the details here.

Updated Rails Routing Guide

Updated the Rails Routing Documentation.

Read all the details here.

Updated TimeWithZone#inspect to match Ruby 1.9+ ISO 8601 format

This updates TimeWithZone#inspect to match the ISO 8601 style time which Ruby has used for Time#inspect since 1.9+ instead of the variant of rfc822. This makes TimeWithZone match Time's formatting except for the precision in the timestamp and including the zone's name.

This only impacts TimeWithZone#inspect, TimeWithZone#to_s had already been updated to use the new ISO 8601 style formatting. Because #inspect should just be used for presenting the time to developers, I don't think we need do go through a deprecation cycle for it.

Before:

After:

Read all the details here.

Allowed registering test directories for CodeStatistics

This change makes it easier for third-party gems, to register test directories.

For example, currently appends to the TEST_TYPES constant:

With this change, it can be simplified to:

Read all the details here.

Allowed BroadcastLogger to pass through kwargs

This Pull Request changes logging methods from explicit argument delegation info to implicit argument delegation info(...).

Read all the details here.

Fixed authentication generator double signature

Before this commit, the session ID stored in the cookies was signed twice:

  • Once with

  • Once with

This commit removes the double signature.

Read all the details here.

Silenced healthcheck requests from the log

The default Rails health check is intended to be hit every second or so by Kamal to ensure that the application is still or has just become responsive. This clutters up the production logs and makes it hard to follow what's actually going on. This adds a new middleware called that is used by a new config to prevent that.

Read all the details here.

Deprecated Benchmark.ms and add benchmark to the gemspec

Ruby plans to make benchmark a bundled gem - This change sets up the deprecation of Rails core extension in favour of the bundled gem for the future.

Read all the details here.

Enabled DependencyTracker to evaluate interpolated paths

Previously, neither the PrismRenderParser nor the RipperRenderParser would consider an interpolated string as a dependency. The RubyTracker even included a line to explcitly filter out interpolated paths returned from the RipperRenderParser since they would end in a "/". However, the RubyTracker does include the ability to evaluate explicit "Template Dependency" comments with wildcard nodes.

This commit extends the RipperRenderParser and PrismRenderParser to convert interpolated strings into wildcard globs. Additionally, it changes the RubyTracker to evaluate wildcards the same for both implicit and explicit dependencies. This enables the RubyTracker to identify potential dependencies for interpolated renders, which it was previously unable to do.

Read all the details here.

alias_attribute: handle user defined source methods

Before this change, when using and trying to alias user defined source methods would error, for example:

This change fixes alias_attribute behavior to handle user defined source methods properly.

Read all the details here.

Fixed .left_outer_joins when multiple associations have the same child

This Pull Request has been created to fix an issue where .left_outer_joins used with multiple associations that have the same child association but different parents does not join all parents.

Read all the details here.

Made automatic detection of processor count in default puma config optional and non-default

This Pull Request changes:

  • Make spawn only 1 worker by default if is not set

  • Modify default puma.rb to offer "auto" as an option for

  • Enhance comment in default deploy.yml to offer "auto" as an option for

  • Update note to t to explain the

Read all the details here.

Deprecated unsigned_float and unsigned_decimal short-hand column methods

As of MySQL 8.0.17, the UNSIGNED attribute is deprecated for columns of type FLOAT, DOUBLE, and DECIMAL.

This change deprecates and short-hand column methods.

Read all the details here.


And that is it, for now, I will be back with more updates next month ✌🏻


Get your copy of Ruby on Rails for Agile Web Development here:

To view or add a comment, sign in

Others also viewed

Explore topics