Forum: Ruby on Rails TypeError (Mail is not a module)

Posted by FredO (Guest)
on 2011-08-24 19:01
(Received via mailing list)
I stepped through the introduction on Action Mailer Basics here:

         http://edgeguides.rubyonrails.org/action_mailer_basics.html

up through 2.1.3,

In 2.1.4, I already had a user class, so I just copied the line

        UserMailer.welcome_email(@user).deliver

into my user_controller/action, modifying it to

        UserMailer.welcome_email(user, contact).deliver

since I had a user and a contact I wished to reference from the body
of the email message.

When the application tries to execute that line I get the following
error:

        TypeError (Mail is not a module):

          app/mailers/user_mailer.rb:1:in `<top (required)>'

          app/controllers/users_controller.rb:285:in `mail_contact'

          app/controllers/users_controller.rb:409:in `add_contact'


user_mailer.rb looks like this:
--------------------------------------------------------------------------------
class UserMailer < ActionMailer::Base

  #include R18n::Helpers



  def welcome_new_contact(user, contact)

    @user = user

    @senior = user.senior



    mail(from: user.email, to: contact.email, subject:
t.welcome_new_contact(@senior.nickname || @senior.firstname))

  end

end
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.