Fixes comment notifications mailers

It was not commendable independent so avery email related with a comment on a proposal was not being sent. Removes dependency on debates and makes it commentable independent.
This commit is contained in:
Juanjo Bazán
2015-09-24 12:41:11 +02:00
parent 5df7917c24
commit 3f46b27371
4 changed files with 38 additions and 9 deletions

View File

@@ -4,23 +4,23 @@ class Mailer < ApplicationMailer
def comment(comment)
@comment = comment
@debate = comment.debate
mail(to: @debate.author.email, subject: t('mailer.comment.subject'))
@commentable = comment.commentable
mail(to: @commentable.author.email, subject: t('mailers.comment.subject', commentable: t("activerecord.models.#{@commentable.class.name.downcase}").downcase)) if @commentable.present? && @commentable.author.present?
end
def reply(reply)
@reply = reply
@debate = @reply.debate
@commentable = @reply.commentable
parent = Comment.find(@reply.parent_id)
@recipient = parent.author
mail(to: @recipient.email, subject: t('mailer.reply.subject'))
mail(to: @recipient.email, subject: t('mailers.reply.subject')) if @commentable.present? && @recipient.present?
end
def email_verification(user, recipient, token)
@user = user
@recipient = recipient
@token = token
mail(to: @recipient, subject: "Verifica tu email")
mail(to: @recipient, subject: t('mailers.email_verification.subject'))
end
end