Rails 3: ActionMailer - PullRequest
       7

Rails 3: ActionMailer

0 голосов
/ 22 марта 2011

Я слежу за этим Railscast здесь для отправки писем из моего приложения rails.

Сначала я попытался настроить перехватчик почты, как в учебнике, но я далв итоге, потому что у меня всегда было прекрасное can't convert nil into Hash (TypeError).

Теперь, когда я не учел перехватчика, я хотел на самом деле отправить письмо, но угадайте, что - мой старый друг вернулся:

can't convert nil into Hash (TypeError)

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

Вот класс почтовика (строка # 20 - это тот, в котором вызывается почта):

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 beim Verwenden des Systems!

спасибо за любую помощь

1 Ответ

0 голосов
/ 11 мая 2011

сделал это, у меня была ошибка в конфиге actionmailer

...