devise icon indicating copy to clipboard operation
devise copied to clipboard

Fixing Zeitwerk errors when running Devise without ActionMailer

Open aldent95 opened this issue 2 years ago • 3 comments

This fixes the longstanding issue #5140 where Zeitwerk throws errors around when using Devise without ActionMailer.

Overall behaviour shouldn't be effected. The new empty class is only used when the application would otherwise error our (ActionMailer not available and Zeitwerk enabled)

aldent95 avatar Apr 23 '22 10:04 aldent95

What is the use for .zeitwerk_enabled? clause in the first place? Wouldn't it be possible just to have the empty class if ActionMailer is not there?

.zeitwerk_enabled? was introduced around Rails 6.0 and devise is backward compatible with Rails 4 (I guess), so this condition may cause issues in earlier versions.

lxxxvi avatar Sep 05 '22 18:09 lxxxvi

Is there any real damage if it just defines the class if ActionMailer is not defined? I understand that adding the rule makes it more focused on solving the error. But it adds a new dependency, so now we don't need ActionMailer but we need Zeitwerk.

I added Devise::Mailer on an initializer and seems to work alright.

If possible, I would just define the class and leave it empty if there is no ActionMailer

lomefin avatar Jan 09 '23 16:01 lomefin

Would devise even work without Action Mailer? So many of its default modules requires a mailer to exist.

Can you provide how you are planning to use Devise without a mailer?

rafaelfranca avatar Jun 09 '23 23:06 rafaelfranca