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

Deprecation Warning with Rails 6.1 & Zeitwerk #30

Open
jwigal opened this issue May 19, 2021 · 0 comments
Open

Deprecation Warning with Rails 6.1 & Zeitwerk #30

jwigal opened this issue May 19, 2021 · 0 comments

Comments

@jwigal
Copy link

jwigal commented May 19, 2021

I realize this is a project that isn't currently maintained, so we're just leaving this here for other people who run into this issue.

Tracked down the following issue related to actionmailer_inline_css. We're seeing deprecation warnings while upgrading to Rails 6.1:

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.

Once we removed actionmailer_inline_css from our gemfile, problem went away.

This matches up with the following Rails issue: rails/rails#36546

Problem appears to be here:

ActionMailer::Base.register_interceptor ActionMailer::InlineCssHook

which is being called on initialization.

I believe the new way in Rails 6 and Zeitwerk is to do something like this:

ActiveSupport.on_load(:action_mailer) do
  ActionMailer::Base.register_interceptor ActionMailer::InlineCssHook
end

We'll be doing our own thing, so if someone wants to provide a pull request or something else to fix this, feel free to do so.

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

No branches or pull requests

1 participant