Welcome to the 35th Edition of Ruby on Rails Monthly - Sajjad here with some exciting updates from Ruby on Rails world.
Before we jump into Rails - I have some news to share:
I am blessed with a baby boy 🥳🥳🥳🥳 (Alhamdulillah).
As I was on leave taking care of my newborn baby, I got a chance to finally work on AdexWorld (https://adex.world) - I’m glad to announce that the beta version is finally ready to share with the world.
I’m looking for 10 integration partners for Adex.world (these partners will have some exclusive signup perks, that I have shared on my LinkedIn here.
Learn more about Adex at https://adex.world
Now, without further ado - let’s jump right into the updates!
Rails 8.0 Has Been Released!
Rails 8.0 is out with a promise of; no PAAS required.
Check out the official announcement here.
With New Rails Comes New Demo Video
Rails 8 - now has a new demo video - a long-awaited update to the official Rails demo.
Rails Guide Is Improving
New PR for Action Controller Overview and Advanced Topics is open for review. Have a look at PR here.
Improve accessibility - this PR aims to improve the accessibility of the guides. Have a look at PR here.
ActionMailer Guide - This Pull Request is for updating and improving the "Action Mailer Basics" Rails Guide documentation. Have a look at PR here.
A Recap of Rails World - All Talks are out!
All the talks from Rails World 2024 are now available online! Revisit your favorite sessions or catch up on the ones you missed on the Rails World 2024 YouTube playlist.
Have a look at this post for details.
New Security Patch Releases for Rails Versions
Rails Versions 6.1.7.9, 7.0.8.5, 7.1.4.1, and 7.2.1.1 have been released!
These are security patches addressing 4 possible ReDoS (Regular expression Denial of Service) attacks. All of these only affect Ruby versions below 3.2 so we urge users on older versions of Ruby to upgrade to these new Rails versions at their earliest convenience.
Additionally we strongly recommend users upgrade to Ruby 3.2 or greater, to take advantage of the improved ReDoS mitigations in newer versions.
Read all the details here.
Rails maintenance policy updated
We’re excited to announce updates to our maintenance policy for Ruby on Rails.
These changes are designed to provide clarity on our support timelines and help you plan your Rails upgrades effectively.
You can find the full details of our new policy here.
ActiveRecord: Added support for disabling transactions per database
This pull request adds a new method to TestFixtures
, set_database_transactions
that allows you specify if a connection should enable or disable transactions for a specific database. This is in addition to the use_transactional_tests
setting to disable or enable transactions for all connections; if there is no preference for a database set by the new method, the default is to follow what use_transactional_tests
defines. You can also specify nil with set_database_transactions
to mean use the default behavior.
Have a look at the PR here.
Debugging: Fixed running with BACKTRACE=1 truncating gem paths
#50563 changed the way that backtraces from gems are shown when running with BACKTRACE=1.
activesupport (7.2.1) lib/active_support/executor/test_helper.rb:5:in 'block in run'
looks nice but isn't immediately useful. This PR restores gem paths to their original, full form.
PR has details on before and after. Have a look at PR here.
Fixed deprecation warning caused by DST
Clarify our logic for detecting whether the current Time value is in the system's local timezone (i.e. that getlocal would be a no-op).
This fixes the fact that we would previously needlessly produce a deprecation warning when encountering a still-local value from the opposite DST state from the one we had cached in active_support_local_zone
.
Have a look at the PR for more details here.
ActiveRecord: Now Cast query_cache value when using URL configuration
When configuring the Active Record connection with DATABASE_URL, the query cache was not set to the given value due to not casting the value to an integer. This pull request fixes this issue.
Have a look at PR here.
Added prefix address when IPAddr of CIDR encoded with JSON
This Pull Request changes IPAddr
of CIDR
is encoded with JSON
add prefix address.
It uses the native IPAddr#as_json
, if use ipaddr
gem v1.2.7+.
ipaddr = IPAddr.new('172.16.0.0/24')
=> #<IPAddr: IPv4:172.16.0.0/255.255.255.0>
ActiveSupport::JSON.encode(ipaddr)
=> "\"172.16.0.0/24\"" # it was returned "\"172.16.0.0\"" which had been removeed address prefix (`/24`)
Have a look at PR here.
Fixed bundle install for vendor gems
The current Dockerfile generator creates the file that will fail for any vendor gems to be installed with a message like:
8.010 The path "/rails/vendor/useragents" does not exist.
This Pull Request adds missing COPY for the vendor folder to allow building vendor gems.
Have a look at PR here.
The default value for Regexp.timeout
has changed to 1s
To avoid Denial of Service attacks of regular expressions on Rails applications we are now configuring the default timeout to 1s.
If a timeout was already configured we don't override it.
Have a look at PR here.
Now Rails authenticates the action cable connection with the existing session model
We can lean on the existing session model to authenticate the action cable web sockets connection too.
Have a look at PR here.
Expanded the documentation of .attributes_for_inspect
Tag .attributes_for_inspect
as a singleton method so it shows up in the API documentation.
This PR expands the documentation of #inspect
and #full_inspect
with examples, and how the output can be changed by .attributes_for_inspect.
Have a look at PR here.
Fixed NoMethodError
when content type is set to nil
in tests
This Pull Request changes ActionController::TestCase
's content type check to account for nil
content types, so Rails can raise a more descriptive Unknown Content-Type error instead of a slightly obscure NoMethodError
.
Have a look at PR here.
Fixed db:migrate:reset task
db:migrate:reset
was broken, because it started to load the schema before migrating. This prevents migrations from running. This patch empties the schema before migrating, ensuring that migrations run as expected.
Have a look at PR here.
Supported Prism for ActionView::Template.spot
This change adds support for the Prism parser with ErrorHighlight
in Rails.
Have a look at PR here.
Do more request parameter parsing on the Rails end
Rack is looking at some minor changes to how they parse query strings. To be more independent of these upstream changes when handling various scenarios, this Pull Request introduces various improvements to handle parsing more on the Rails side.
Have a look at PR here.
Improved ActionController::TestCase
to expose a binary-encoded request.body
The rack spec clearly states:
The input stream is an IO-like object which contains the raw HTTP POST data.
When applicable, its external encoding must be “ASCII-8BIT” and it must be opened in binary mode.
Until now its encoding was generally UTF-8, which doesn't accurately reflect production behavior. This PR fixes the issue.
Have a look at PR here.
Made internal query() retryable
This commit makes all internal SELECT query()s retryable so that they can be used as connection verification. While this likely won't help as much in production for applications using a schema cache dump, it will definitely decrease latency for applications in development and those that do not use a dump in production.
There are a few places where query_value was used to update sequences. Those have been changed to use internal_execute since only idempotent SELECT queries are being automatically retried and Active Record doesn't actually care about the return value of these queries anyways (so no reason to use internal_exec_query).
Have a look at PR here.
Update vendored Trix version to 2.1.7
his updates Trix to 2.1.7, which includes support for the upcoming security fix and enhanced form support (ElementInternals and HTML5 validations).
Have a look at PR here.
Fixed marshaling of unsaved associated records in 7.1 format
The 7.1 format would only marshal associated records if the association was loaded. However, associations that would only contain unsaved records would be skipped.
This PR fixes the issue.
Have a look at PR here.
Deprecated setting config.active_job.enqueue_after_transaction_commit
The active_job.enqueue_after_transaction_commit
setting has been deprecated. This behavior is not intended to be changed globally but on a per-job basis.
Have a look at PR here.
Added support for using Kamal inside of the generated devcontainer
Kamal requires Docker to run. The docker-in-docker devcontainer feature allows running Docker inside the container.
So, now you can use Kamal when running Rails in the devcontainer.
Have a look at PR here.
Reduced allocations in AS::Duration#{since,ago}
This change reduces the number of allocations by a very small amount but is interesting if you're learning about optimization and benchmarks.
Read all the details here.
Fixed strict loading propagation even if statement cache is not used
Currently, strict loading propagation works only if statement cache is used. This fixes that works even if statement cache is not used.
Have a look at PR here.
Fixed enum labels to accept as keyword arguments
Now you can define enums without the extra brackets using keyword arguments.
# Before
enum :status, { default: 0, scopes: 1, prefix: 2, suffix: 3 }
# After
enum :status, default: 0, scopes: 1, prefix: 2, suffix: 3
Have a look at PR here.
Allowed rename_enum
accepts two from/to
name arguments as rename_table
does so
It looks odd that rename_enum requires two from/to name arguments but accepts one as an option.
This PR allows rename_enum accepts two from/to name arguments as rename_table does so.
Have a look at PR here.
Translated no connection to the server to ConnectionNotEstablished
This PR changes PostgreSQLAdapter#translate_exception
to translate PG::UnableToSend: no connection to the server
to ConnectionNotEstablished
as same as "connection is closed
".
Have a look at PR here.
Fixed CurrentAttributes#attributes
to return new object each time
Now calling Current.attributes
will return a new object each time it is called.
Have a look at PR here.
That is all for this month - I will be back with more updates in the next edition of the Ruby on Rails monthly newsletter. ✌🏻