Skip to content

Commit 0f9aaa5

Browse files
authored
Merge pull request rails#51039 from rails/update-release-notes
Update 7.0 release notes re inflections and the once autoloader
2 parents 1a92af2 + 5876939 commit 0f9aaa5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

guides/source/upgrading_ruby_on_rails.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,20 @@ to be an error condition in future versions of Rails.
477477

478478
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.
479479

480+
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`:
481+
482+
```ruby
483+
module MyApp
484+
class Application < Rails::Application
485+
# ...
486+
487+
ActiveSupport::Inflector.inflections(:en) do |inflect|
488+
inflect.acronym "HTML"
489+
end
490+
end
491+
end
492+
```
493+
480494
### Ability to configure `config.autoload_once_paths`
481495

482496
[`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/*`.

0 commit comments

Comments
 (0)