Rails 6.1.5: 未初始化常量 Mail::TestMailer

Rails 6.1.5: uninitialized constant Mail::TestMailer

为什么我在使用“Rails 6.1.5 & Ruby 3.1.0”时出现 'uninitialized constant Mail::TestMailer' 错误,而“Rails 6.1.5 & Ruby 3.0.1" ?

NEWS for Ruby 3.1.0 中找到以下内容。

The following default gems are now bundled gems.

net-ftp 0.1.3
net-imap 0.2.2
net-pop 0.1.1
net-smtp 0.3.1
matrix 0.4.2
prime 0.1.2
debug 1.4.0

所以,我刚刚将接下来的 3 行添加到 GemFile 中。效果很好。

gem 'net-smtp' # to send email
gem 'net-imap' # for rspec
gem 'net-pop'  # for rspec