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

Fix Zeitwerk autoloading when ActionMailer is not present. #5731

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

nashby
Copy link
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

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 merged commit 7eccc91 into main Nov 25, 2024
40 checks passed
@nashby nashby deleted the fix-without-mailer-load branch November 25, 2024 12:57
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
1 participant