Ask A Question

Notifications

You’re not receiving notifications from this thread.

Action mailer rails 6

Pratima Singh asked in Rails

Hey Chris,

cannot send email from console using UserMailer.welcome_email.perform_now, geting this error

Traceback (most recent call last):
        1: from (irb):3
NameError (uninitialized constant UserMailer
irb(main):004:0> 

why is it saying (uninitialized constant UserMailer)

Reply

cannot send email from console using in rails 6

EmailMailer.welcome.perform_now
Traceback (most recent call last):
2: from (irb):2
1: from (irb):2:in `rescue in irb_binding'
NameError (uninitialized constant EmailMailer)

my EmailMailer

class EmailMailer < ApplicationMailer

def welcome
@greeting = "Hi"

mail to:  my_email_address

end
end

Reply

I'm having the same problem in Rails 6.0.2. After generating a mailer UserMailer, running it in console results the following:

irb(main):001:0> UserMailer
Traceback (most recent call last):
        1: from (irb):1
NameError (uninitialized constant UserMailer)

I've checked the file names and everything is named correction (user_mailer.rb and the class is UserMailer).

Oddly enough, running ApplicationMailer in the console is recognised.

irb(main):003:0> ApplicationMailer
=> ApplicationMailer

Has something changed since rails 5 where you can't run mailer actions from the console?

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.