Skip to content

Authentication generator breaks apps with action_mailer/railtie disabled #54501

@ramimassoud

Description

@ramimassoud

Steps to reproduce

  1. Create a Rails 8 application with require "action_mailer/railtie" commented out in config/application.rb
  2. Run bin/rails generate authentication
  3. Boot the app in production mode or with config.eager_load = true. Also can enter PasswordsMailer in Rails console and try to evaluate the class.

Expected behavior

I believe all of the mailer templates should verify ActionMailer::Base is defined before generating mailer related files

template "app/mailers/passwords_mailer.rb"
template "app/views/passwords_mailer/reset.html.erb"
template "app/views/passwords_mailer/reset.text.erb"
template "test/mailers/previews/passwords_mailer_preview.rb"

Actual behavior

PasswordsMailer is generated inheriting from ApplicationMailer, which does not exist.

System configuration

Rails version: Rails 8.0.1

Ruby version: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions