Send e-Mail to all commenters if thank you note is given

This commit is contained in:
Maximilian Grundke
2017-06-09 14:40:44 +02:00
parent 30375a4909
commit eaac43ac63
5 changed files with 86 additions and 0 deletions

View File

@ -37,6 +37,13 @@ class RequestForCommentsController < ApplicationController
def set_thank_you_note
authorize!
@request_for_comment.thank_you_note = params[:note]
commenters = []
@request_for_comment.comments.distinct.to_a.each {|comment|
commenters.append comment.user
}
commenters = commenters.uniq {|user| user.id}
commenters.each {|commenter| UserMailer.send_thank_you_note(@request_for_comment, commenter).deliver_now}
respond_to do |format|
if @request_for_comment.save
format.json { render :show, status: :ok, location: @request_for_comment }