Reputation: 91
After setting up mailer (3.2.6) in Ruby on rails (3.2.6) I get this error:
NoMethodError (undefined method `mail' for #):
my user_mailer.rb looks like this:
class UserMailer < ActionMailer::Base
default :from => "[email protected]"
def activation_mail(user)
@user = user
mail(:to => user.mail, :subject => "Registration")
end
end
I followed example provided here: http://guides.rubyonrails.org/action_mailer_basics.html
In configuration file I added this line: config.action_mailer.delivery_method = :test I also tried with :smtp and configuration for gmail.
What have I missed?
Upvotes: 9
Views: 6822
Reputation: 774
I found that a typo in your mailer view can cause this problem. The error message is misleading.
Upvotes: 0
Reputation: 41
I had a similar problem recently and rectified it by replacing:
def self.activation_mail()
with
def activation_mail()
Upvotes: 4
Reputation: 105
you should try replacing
def activation_mail(user)
@user = user
mail(:to => user.mail, :subject => "Registration")
end
with
def activation_mail(user)
@user = user
mail(:to => @user.mail, :subject => "Registration")
end
Upvotes: 3
Reputation: 31
It's a typo error. Your user.mail doesn't exist. Maybe it should be user.email or something else.
Upvotes: 2
Reputation: 2111
I bet your "user" object you're passing is either 1) not instantiated correctly, or 2) an array instead of an individual User object
Upvotes: 0