rabl-rails icon indicating copy to clipboard operation
rabl-rails copied to clipboard

Rails 6 warning: autoloading ActionController::Base during initialization

Open danrice92 opened this issue 4 years ago • 2 comments

Hello,

When upgrading our project that uses our gem to Rails 6 in Zeitwerk mode (setting config.load_defaults to "6.0"), we found that running our test suite output this warning:

DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper.

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 ActionText::ContentHelper, for example,
the expected changes won't be reflected in that stale Module object.

These autoloaded constants have been unloaded.

In order to autoload safely at boot time, please wrap your code in a reloader
callback this way:

    Rails.application.reloader.to_prepare do
      # Autoload classes and modules needed at boot time here.
    end

That block runs when the application boots, and every time there is a reload.
For historical reasons, it may run twice, so it has to be idempotent.

Check the "Autoloading and Reloading Constants" guide to learn more about how
Rails autoloads and reloads.

This is because line 24 of lib/rabl-rails/configuration.rb calls ActionController::Base without the suggested to_prepare block wrapping it.

Is this something that can be tweaked in a future release to silence the warning/avoid future errors?

danrice92 avatar Mar 11 '21 23:03 danrice92

We use the same version and our working to update to Rails 7. We use rabl-rails pretty extensively. We have not encountered this warning with rabl-rails though. Is the warning still occurring for you?

javierjulio avatar May 20 '23 14:05 javierjulio

We use the same version and our working to update to Rails 7. We use rabl-rails pretty extensively. We have not encountered this warning with rabl-rails though. Is the warning still occurring for you?

I am not seeing it currently, but I'm not sure if that's because the error was addressed or because we changed our code to get around this somehow.

danrice92 avatar May 22 '23 15:05 danrice92