ccocchi / rabl-rails

Rails 4.2+ templating system with JSON, XML and Plist support.
MIT License
209 stars 51 forks source link

Rails 6 warning: autoloading ActionController::Base during initialization #96

Open danrice92 opened 3 years ago

danrice92 commented 3 years ago

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?

javierjulio commented 1 year ago

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?

danrice92 commented 1 year ago

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.