! (again)

This commit is contained in:
nilsding 2014-12-08 12:34:48 +01:00
parent 384cc7f5ea
commit 7b5454a1bd
1 changed files with 3 additions and 4 deletions

View File

@ -3,7 +3,7 @@ class Inbox < ActiveRecord::Base
belongs_to :question belongs_to :question
def answer(answer, user) def answer(answer, user)
Answer.create(content: answer, Answer.create!(content: answer,
user: user, user: user,
question: self.question) question: self.question)
user.increment! :answered_count user.increment! :answered_count
@ -12,7 +12,6 @@ class Inbox < ActiveRecord::Base
end end
def remove def remove
self.question.decrement! :answer_count
unless self.question.user.nil? unless self.question.user.nil?
self.question.user.decrement! :asked_count if self.question.answer_count == 1 self.question.user.decrement! :asked_count if self.question.answer_count == 1
end end