开发者

Rails 3: ActionMailer

I'm following this Railscast here for sending mails from my rails app.

At first I tried to set up a mail intercepto开发者_开发知识库r like in the tutorial, but I've given up on that, because I always got a lovely can't convert nil into Hash (TypeError).

Now that I left out the interceptor, I wanted to actually send a mail, but guess what - my old friend is back:

can't convert nil into Hash (TypeError)

app/mailers/user_mailer.rb:20:in `registration'

Here's the mailer class (line #20 is the one with the call to 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

The log shows:

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!

And here's the requested view file (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 beim Verwenden des Systems!

thx for any help


did it, I had an error in actionmailer's config

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜