Reputation: 101
in user.rb
after_create :welcome_message
def welcome_message
UserMailer.welcome_email(self.email).deliver
end
in routes devise_for :users
in usermailer
def welcome_email(user)
@user = user
mail(:to => user.email,
:subject => "Welcome to Vancouver Presales!")
end
I have this error:
Missing template user_mailer/welcome_email with "mailer". Searched in: * "user_mailer"
please any one tell me whats the wrong?
Upvotes: 0
Views: 306
Reputation: 10251
Missing template user_mailer/welcome_email with "mailer". Searched in: * "user_mailer"
states that it is going to look for template for speciic mailer's method but you have not created yet so you are getting this error. Create template with the mailer_method_name.html.erb
under app/views/your_mailer/mailer_method_name.html.erb
Like this Create Template for UserMailer
under:
app/views/user_mailer/welcome_email.html.erb
# you can design your template here how it should look when user receive the mail
<h1>Welcome <%= @user.name.present? ? @user.name : @user.email %> to Vancouver Presales! </h1>
....
Upvotes: 4
Reputation: 202
You need to create a template having same name as your method name which is sending an email. So you need to create a template here in directory app/views/user_mailer/welcome_email.html.erb your email content will go in this template
Upvotes: 0