Skip to content

Instantly share code, notes, and snippets.

@marclove
Created March 5, 2014 23:06
Show Gist options
  • Save marclove/9378626 to your computer and use it in GitHub Desktop.
Save marclove/9378626 to your computer and use it in GitHub Desktop.
class CommentsController
def create
@comment = Comment.create(params[:comment])
CommentCreatedWorker.perform_async(@comment.id)
respond_with @comment
end
end
class CommentCreatedWorker
include Sidekiq::Worker
def perform(comment_id)
comment = Comment.find(comment_id)
comment_thread = comment.comment_thread
comment_thread.participants.each do |participant|
CommentThreadMailer.activity_notification(comment_thread, comment, participant)
end
if comment.previous_comment?
in_reply_to_user = comment.previous_comment.author
ReplyMailer.notification(in_reply_to_user, comment).deliver
end
Kissmetrics.record(comment.author, 'Added Comment')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment