From 5876939a5a5cfa9099ab8d2d08f6e05283d81cae Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 10 Feb 2024 12:42:40 +0100 Subject: [PATCH] Update 7.0 release notes re inflections and the once autoloader --- guides/source/upgrading_ruby_on_rails.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index e3e96b01e6..03a26731e2 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -477,6 +477,20 @@ to be an error condition in future versions of Rails. If you still get this warning in the logs, please check the section about autoloading when the application boots in the [autoloading guide](https://guides.rubyonrails.org/v7.0/autoloading_and_reloading_constants.html#autoloading-when-the-application-boots). You'd get a `NameError` in Rails 7 otherwise. +Constants managed by the `once` autoloader can be autoloaded during initialization, and they can be used normally, no need for a `to_prepare` block. However, the `once` autoloader is now set up earlier to support that. If the application has custom inflections, and the `once` autoloader should be aware of them, you need to move the code in `config/initializers/inflections.rb` to the body of the application class definition in `config/application.rb`: + +```ruby +module MyApp + class Application < Rails::Application + # ... + + ActiveSupport::Inflector.inflections(:en) do |inflect| + inflect.acronym "HTML" + end + end +end +``` + ### Ability to configure `config.autoload_once_paths` [`config.autoload_once_paths`][] can be set in the body of the application class defined in `config/application.rb` or in the configuration for environments in `config/environments/*`.