chaynHQ / soulmedicine

Soul Medicine a multilingual digital service designed to deliver critical safety information and supportive messaging in bite-sized pieces.
https://soulmedicine.io
MIT License
38 stars 9 forks source link

Fix autoloaded constant deprecation warning #348

Closed tarebyte closed 1 year ago

tarebyte commented 1 year ago

We were getting the following warning after upgrading to zeitwerk mode.

DEPRECATION WARNING: Initialization autoloaded the constant LocalesService.

Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.

Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload LocalesService, for example,
the expected changes won't be reflected in that stale Module object.

This autoloaded constant has been unloaded.

Please, check the "Autoloading and Reloading Constants" guide for solutions.
 (called from <main> at /home/runner/work/soulmedicine/soulmedicine/config/environment.rb:15)

To fix this we are requiring the LocaleService explicitly as recommended by https://guides.rubyonrails.org/v6.0/autoloading_and_reloading_constants.html#ruby-constant-lookup-compliance