close
close

Ruby on Rails β€” Rails 7.2 released, Default Thruster for Rails 8, new PR Guides and more!

Ruby on Rails β€” Rails 7.2 released, Default Thruster for Rails 8, new PR Guides and more!

Monday August 12, 2024

Rails 7.2 released, Default Thruster for Rails 8, new PR Guides and much more!

Posted by vipulnsward

Hello everyone, happy Monday! Vipul here with the latest updates from This Week in Rails (from last week πŸ˜…). Let’s dive in.

Rails 7.2 is out
Rails 7.2 is out!

Head over to the release post for more details, but in short, it comes with better production defaults, development containers, a new guide design, and much more!

New Pull Requests Guides for Review
Two new guide pull requests are now open for community review. If you’re familiar with Rails routing and active record associations, please check them out and submit your feedback here:

Use Thruster by default for Rails 8
Thruster is an X-Sendfile-accelerated asset compression and caching proxy that speeds up simple deployments of production-ready Rails applications. It works alongside Puma and typically behind the Kamal 2 proxy, which offers automatic HTTP/2 and SSL certificates, to help your application run efficiently and securely on the open Internet.

This change configures the use of Thruster in the Dockerfile by default, starting with Rails 8.

Accelerate ActionDispatch::Routing::Mapper::Scope#() by merging frame hashes
Before this change, ActionDispatch::Routing::Mapper::Scope#() the search iterated over an array, meaning the access time was not constant and did not actually behave like a hash.

This pull request changes the scope implementation to make lookup faster by simply merging inherited values ​​into the immediate hash.

This helps avoid unnecessary iterations for deeply nested routes, which leads to them being ~1.2x faster.

Remove redundant Puma configuration settings
This pull request removes the following redundant environment settings in puma.rb:

# Specifies the `environment` that Puma will run in.
rails_env = ENV.fetch("RAILS_ENV", "development")
environment rails_env

case rails_env
when "production"
  preload_app!
when "development"
  # Specifies a very generous `worker_timeout` so that the worker
  # isn't killed by Puma when suspended by a debugger.
  worker_timeout 3600
end

These changes respond to recent Puma upgrades which-

  • Puma now automatically sets its environment from RAILS_ENV.
  • preload_app! is automatically set to cluster mode.
  • worker_timeout is a feature of cluster mode, and we don’t run it in development.

Another change made to Puma is that WEB_CONCURRENCY is automatically used from ENV and is now parsed directly, so it cannot be extended with “auto” in Puma configuration.

This related change fixes this issue and removes the redundant dynamic parameter for the value of puma.rb

Improve default action mail configuration
This Pull Request introduces some improvements to the default Action Mailer configuration:

  • Suggest a default SMTP server configuration in a comment in production.rb.
  • Sets a default example.com host for production email links as well.
  • Use the same comment style in all environment settings for the mail host.

Make auto-detection of number of processors in default Puma configuration optional and not default
By using Concurrent.available_processor_count default assistant in puma.rb The model may cause incorrect configurations on some cloud hosts with shared CPUs or platforms that inaccurately report the number of CPUs.

This pull request changes this default configuration to be optional and not the default.

Let allow_browser allow robots
THE allow_browser This feature blocks requests with user agents that do not match a specific set of browser versions. This may prevent sites from being crawled by some search engines.

This change fixes this behavior to work around these version restrictions for some crawlers and bots.

Allow calling disable_extension with schema-qualified name for PostgreSQL
This change allows disable_extension to be called with a schema-qualified name for PostgreSQL.

This adds parity with enable_extensionTHE disable_extension the method can be called with a schema-qualified name (eg disable_extension "myschema.pgcrypto"). Note that PostgreSQL DROP EXTENSION does not actually take a schema name (unlike CREATE EXTENSION), so the resulting SQL statement will only name the extension, e.g. DROP EXTENSION IF EXISTS "pgcrypto".

You can see the full list of changes here.
We had 36 contributors to the Rails codebase last week!

See you next time!

Subscribe to receive these updates by mail.