我在这里关注通过我的rails应用程序发送邮件的this Railscast。
起初,我尝试设置一个邮件拦截器,就像本教程中那样,但我已经放弃了,因为我总是得到一个可爱的can't convert nil into Hash (TypeError)。
现在我省略了拦截器,我想实际发送一封邮件,但是猜猜发生了什么--我的老朋友回来了:
can't convert nil into Hash (TypeError)
app/mailers/user_mailer.rb:20:in `registration'下面是mailer类(第20行是调用mail的那行):
class UserMailer < ActionMailer::Base
def registration( user )
@invited = user
subject = 'Welcome!'
if Rails.env.development?
to = 'my.private@email.com'
subject = "to #{@invited.email}: #{subject}"
else
to = @invited.email
end
logger.info "Sending email to #{to} with subject #{subject}"
mail( :from => 'noreply@mysite.com', :to => to, :subject => subject )
end
end日志显示:
invite entered for user foo@bar.com
Sending email to foo@bar.com
Sending email to my.private@email.com with subject to foo@bar.com: Welcome!下面是请求的视图文件(registration.text.erb):
Welcome!
blablah blah click the following link to activate blah blah <%= activate_user_path( @invited )%> blah blah.
blah blah this is actually german (but plaintext) encoded in utf-8. Viel Vergnügen北京Verwenden des系统!
thx寻求任何帮助
发布于 2011-05-11 17:32:03
这样做了,我在actionmailer的配置中有一个错误
https://stackoverflow.com/questions/5395608
复制相似问题