Rails 6.1.5: uninitialized constant Mail::TestMailer
Asked Answered
H

3

8

Why am i getting 'uninitialized constant Mail::TestMailer' error with "Rails 6.1.5 & Ruby 3.1.0" while working without problems "Rails 6.1.5 & Ruby 3.0.1" ?

Houri answered 13/4, 2022 at 4:11 Comment(2)
think you should move your answer to the answers :) you can self-answer questions :)Vladimar
see stackoverflow.com/help/self-answerVladimar
H
7

Found following from 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

So, i just added next 3 lines into GemFile. It worked fine.

gem 'net-smtp' # to send email
gem 'net-imap' # for rspec
gem 'net-pop'  # for rspec
Houri answered 6/5, 2022 at 2:8 Comment(0)
R
1

I had similar issue, after debugging and troubleshooting. I made changes to the Rails version to 6.1.1.4 instead of 6.1.7. The I got similar error stating that it could not load some .rb files from the mail gem. What I did was to give them the read permission to others.

chmod 644 <ruby-file-in-mail-gem>.rb

and the application loaded fine after that.

Roxane answered 2/1, 2023 at 11:44 Comment(0)
M
0

I was getting same issue after deploying the code on server.
Version details-

Rails 6.1.5
ruby 3.1.2p20

I just install a new gem as-

gem 'net-smtp'

and issue got resolved.

Marquettamarquette answered 25/2, 2023 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.