if a question was answered, all occurrences of it in the inbox are now gone

This commit is contained in:
nilsding 2015-01-03 19:02:56 +01:00
parent 72140be316
commit aec3e1c800
1 changed files with 2 additions and 0 deletions

View File

@ -5,6 +5,8 @@ class Answer < ActiveRecord::Base
has_many :smiles, dependent: :destroy
after_create do
Inbox.where(user: self.user, question: self.question).destroy_all
Notification.notify self.question.user, self unless self.question.author_is_anonymous
self.user.increment! :answered_count
self.question.increment! :answer_count