Skip to content

Fix Zeitwerk autoloading when ActionMailer is not present.#5731

Merged
nashby merged 1 commit intomainfrom
fix-without-mailer-load
Nov 25, 2024
Merged

Fix Zeitwerk autoloading when ActionMailer is not present.#5731
nashby merged 1 commit intomainfrom
fix-without-mailer-load

Conversation

@nashby
Copy link
Copy Markdown
Collaborator

@nashby nashby commented Nov 25, 2024

When ActionMailer is not defined we have empty app/mailers/devise/mailer.rb file and Zeitwerk doesn't like that and errors with

expected file app/mailers/devise/mailer.rb to define constant Devise::Mailer

The fix is to tell Zeitwerk to ignore that file if ActionMailer constant if not defined.

I tried to write a spec for it but since specs are run in the same process it's hard to have two Rails applications where one of them has ActionMailer define and the seconds one doesn't.

closes #5140, #5485

@nashby nashby force-pushed the fix-without-mailer-load branch from 1b28cb1 to e5049af Compare November 25, 2024 12:52
When ActionMailer is not defined we have empty app/mailers/devise/mailer.rb file and Zeitwerk doesn't
like that and errors with

```
expected file app/mailers/devise/mailer.rb to define constant Devise::Mailer
```

The fix is to tell Zeitwerk to ignore that file if ActionMailer constant if not defined.

I tried to write a spec for it but since specs are run in the same process it's hard to have two
Rails applications where one of them has ActionMailer define and the seconds one doesn't.
@nashby nashby force-pushed the fix-without-mailer-load branch from e5049af to af112a2 Compare November 25, 2024 12:57
@nashby nashby merged commit 7eccc91 into main Nov 25, 2024
@nashby nashby deleted the fix-without-mailer-load branch November 25, 2024 12:57
thomasleese added a commit to NHSDigital/manage-vaccinations-in-schools that referenced this pull request Feb 12, 2025
This removes various references to `ActionMailer` and the mailer classes
since they are no longer being used as we're sending emails using the
GOV.UK Notify API directly now (#2841).

We can't remove the `ApplicationMailer` and stop requiring
`action_mailer/railtie` until
heartcombo/devise#5731 has been released.
@Faq
Copy link
Copy Markdown

Faq commented Apr 24, 2025

Works as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Rails6 without ActionMailer won't boot with zeitwerk eager-loading

2 participants