Skip to content

Deprecation Warning with Rails 6.1 & Zeitwerk #30

@jwigal

Description

@jwigal

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions