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,6 +96,7 @@ 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)
if @receiver && @sender && @comment
@post_author_name = @comment.post.author.name @post_author_name = @comment.post.author.name
@ -107,6 +108,7 @@ class Notifier < ActionMailer::Base
:subject => "Re: #{comment_email_subject}") :subject => "Re: #{comment_email_subject}")
end end
end end
end
def comment_email_subject def comment_email_subject
truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN) truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN)

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