! (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,16 +3,15 @@ class Inbox < ActiveRecord::Base
belongs_to :question
def answer(answer, user)
Answer.create(content: answer,
user: user,
question: self.question)
Answer.create!(content: answer,
user: user,
question: self.question)
user.increment! :answered_count
self.question.increment! :answer_count
self.destroy
end
def remove
self.question.decrement! :answer_count
unless self.question.user.nil?
self.question.user.decrement! :asked_count if self.question.answer_count == 1
end