devise
devise copied to clipboard
Fixing Zeitwerk errors when running Devise without ActionMailer
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)
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.
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
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?