fix for 'undefined method 'post' for nil:NilClass' in Mail::AlsoCommented

This commit is contained in:
Maxwell Salzberg 2011-09-03 16:06:30 -07:00
parent 1853720513
commit 0780491d4f
2 changed files with 11 additions and 7 deletions

View file

@ -96,15 +96,17 @@ class Notifier < ActionMailer::Base
@sender = Person.find_by_id(sender_id) @sender = Person.find_by_id(sender_id)
@comment = Comment.find_by_id(comment_id) @comment = Comment.find_by_id(comment_id)
@post_author_name = @comment.post.author.name if @receiver && @sender && @comment
@post_author_name = @comment.post.author.name
log_mail(recipient_id, sender_id, 'comment_on_post') log_mail(recipient_id, sender_id, 'comment_on_post')
I18n.with_locale(@receiver.language) do I18n.with_locale(@receiver.language) do
mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>", mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>",
:to => "\"#{@receiver.name}\" <#{@receiver.email}>", :to => "\"#{@receiver.name}\" <#{@receiver.email}>",
:subject => "Re: #{comment_email_subject}") :subject => "Re: #{comment_email_subject}")
end
end end
end end

View file

@ -3,7 +3,9 @@ module Job
class AlsoCommented < Base class AlsoCommented < Base
@queue = :mail @queue = :mail
def self.perform(recipient_id, sender_id, comment_id) def self.perform(recipient_id, sender_id, comment_id)
Notifier.also_commented(recipient_id, sender_id, comment_id).deliver if email = Notifier.also_commented(recipient_id, sender_id, comment_id)
email.deliver
end
end end
end end
end end