From 8b88827a005a1b8e1ca61411f1f17019b1afa9c9 Mon Sep 17 00:00:00 2001 From: Yuki Date: Tue, 5 May 2015 02:36:57 +0530 Subject: [PATCH] Fix retrospring/bugs#43 --- app/controllers/answer_controller.rb | 3 +++ app/models/answer.rb | 1 + 2 files changed, 4 insertions(+) diff --git a/app/controllers/answer_controller.rb b/app/controllers/answer_controller.rb index 9924b9bf..e6abf19c 100644 --- a/app/controllers/answer_controller.rb +++ b/app/controllers/answer_controller.rb @@ -13,6 +13,9 @@ class AnswerController < ApplicationController notif.update_all(new: false) unless notif.empty? notif = Notification.where(target_type: "Smile", target_id: @answer.smiles.pluck(:id), recipient_id: current_user.id, new: true) notif.update_all(new: false) unless notif.empty? + # @answer.comments.smiles throws + notif = Notification.where(target_type: "CommentSmile", target_id: @answer.comment_smiles.pluck(:id), recipient_id: current_user.id, new: true) + notif.update_all(new: false) unless notif.empty? end end end diff --git a/app/models/answer.rb b/app/models/answer.rb index 52568fa8..25ffc23a 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -4,6 +4,7 @@ class Answer < ActiveRecord::Base has_many :comments, dependent: :destroy has_many :smiles, dependent: :destroy has_many :subscriptions, dependent: :destroy + has_many :comment_smiles, through: :comments, source: :smiles after_create do Inbox.where(user: self.user, question: self.question).destroy_all