This commit is contained in:
Yuki 2015-05-05 02:36:57 +05:30
parent 97b27248c2
commit 8b88827a00
2 changed files with 4 additions and 0 deletions

View File

@ -13,6 +13,9 @@ class AnswerController < ApplicationController
notif.update_all(new: false) unless notif.empty? 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 = 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? 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 end
end end

View File

@ -4,6 +4,7 @@ class Answer < ActiveRecord::Base
has_many :comments, dependent: :destroy has_many :comments, dependent: :destroy
has_many :smiles, dependent: :destroy has_many :smiles, dependent: :destroy
has_many :subscriptions, dependent: :destroy has_many :subscriptions, dependent: :destroy
has_many :comment_smiles, through: :comments, source: :smiles
after_create do after_create do
Inbox.where(user: self.user, question: self.question).destroy_all Inbox.where(user: self.user, question: self.question).destroy_all