activeadmin-xls icon indicating copy to clipboard operation
activeadmin-xls copied to clipboard

Extend ActiveAdmin the before_load way instead of within the engines

Open shanser opened this issue 4 years ago • 4 comments

Using the engine causes Rails deprecation warnings because of Autoloading

The PR attacks the same problem as #21 but the problem was not resolved.

The workaround here is to use ActiveAdmin.before_load system instead of the initializer, because ActiveAdmin::ResourceController autoloads a lot of stuff, wich is now deprecated during initialize phase.

Here are the traces that I had before this patch:

DEPRECATION WARNING: Initialization autoloaded the constants CampagneHelper, ApplicationHelper, StructureHelper, AnonymeHelper, ActiveAdmin::ViewsHelper, DeviseHelper, ApplicationController, and InheritedResources::Base.

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 CampagneHelper, 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

shanser avatar Aug 13 '21 11:08 shanser

@thambley did you had the chance to take a look at this PR ? 🙏

shanser avatar Aug 20 '21 10:08 shanser

👋 @thambley , same question as above :)

shanser avatar Sep 09 '21 20:09 shanser

@thambley ? :)

shanser avatar Oct 01 '21 10:10 shanser

@thambley any news for this PR ? :) 🙏

cprodhomme avatar Jun 20 '22 10:06 cprodhomme

With @shanser, we have made a fork on Captive-Studio : https://github.com/Captive-Studio/activeadmin-xls

If someone have the same issue, you can use our fork ;)

cprodhomme avatar Dec 05 '23 12:12 cprodhomme