Skip to content

Commit 7eccc91

Browse files
authored
Merge pull request #5731 from heartcombo/fix-without-mailer-load
Fix Zeitwerk autoloading when ActionMailer is not present.
2 parents 90a3fa8 + af112a2 commit 7eccc91

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@
1919
* Add Rails 8 support.
2020
- Routes are lazy-loaded by default in test and development environments now so Devise loads them before `Devise.mappings` call.
2121
22+
* bug fixes
23+
* Make `Devise` work without `ActionMailer` when `Zeitwerk` autoloader is used.
24+
2225
Please check [4-stable](https://github.com/heartcombo/devise/blob/4-stable/CHANGELOG.md)
2326
for previous changes.

lib/devise/rails.rb

+6
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,11 @@ class Engine < ::Rails::Engine
4747
)
4848
end
4949
end
50+
51+
initializer "devise.configure_zeitwerk" do
52+
if Rails.autoloaders.zeitwerk_enabled? && !defined?(ActionMailer)
53+
Rails.autoloaders.main.ignore("#{root}/app/mailers/devise/mailer.rb")
54+
end
55+
end
5056
end
5157
end

0 commit comments

Comments
 (0)