diff --git a/CHANGELOG.md b/CHANGELOG.md index 0adbeb67a..104b9057e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,5 +19,8 @@ * Add Rails 8 support. - Routes are lazy-loaded by default in test and development environments now so Devise loads them before `Devise.mappings` call. +* bug fixes + * Make `Devise` work without `ActionMailer` when `Zeitwerk` autoloader is used. + Please check [4-stable](https://github.com/heartcombo/devise/blob/4-stable/CHANGELOG.md) for previous changes. diff --git a/lib/devise/rails.rb b/lib/devise/rails.rb index dad9e86dc..b5738853f 100644 --- a/lib/devise/rails.rb +++ b/lib/devise/rails.rb @@ -47,5 +47,11 @@ class Engine < ::Rails::Engine ) end end + + initializer "devise.configure_zeitwerk" do + if Rails.autoloaders.zeitwerk_enabled? && !defined?(ActionMailer) + Rails.autoloaders.main.ignore("#{root}/app/mailers/devise/mailer.rb") + end + end end end