Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning when using Rails 6 zeitwerk autoloading #192

Closed
TheRPunkt opened this issue Sep 1, 2019 · 0 comments · Fixed by #194
Closed

Warning when using Rails 6 zeitwerk autoloading #192

TheRPunkt opened this issue Sep 1, 2019 · 0 comments · Fixed by #194

Comments

@TheRPunkt
Copy link

When using Rails 6 newest autloader zeitwerk I get following warning when starting rails tests:

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.

Please, check the "Autoloading and Reloading Constants" guide for solutions.
 (called from block (2 levels) in included at /my_project_root/config/environment.rb:13)

I believed it's caused by the materialize initializer defined in engine.rb which references ActionController::Base.

maxtilford added a commit to maxtilford/materialize-sass that referenced this issue Jul 8, 2020
Including the gem in a Rails 6 app results in the following error message:
> 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.

This change uses ActiveSupport's onload hook in order to ensure that the materialize helpers are added to the *newly loaded* ActionController::Base, whenever a reload occurs.

Fixes mkhairi#192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant