moved some code
This commit is contained in:
parent
6d81b4a24b
commit
b6c0b1864a
|
@ -11,13 +11,10 @@ class Ajax::AnswerController < ApplicationController
|
|||
return
|
||||
end
|
||||
|
||||
answer.user.decrement! :answered_count
|
||||
answer.question.decrement! :answer_count
|
||||
if answer.user == current_user
|
||||
Inbox.create!(user: answer.user, question: answer.question, new: true)
|
||||
end # TODO: decide what happens with the question
|
||||
Notification.denotify answer.question.user, answer
|
||||
answer.destroy
|
||||
answer.remove
|
||||
|
||||
@status = :okay
|
||||
@message = "Successfully deleted answer."
|
||||
|
|
|
@ -7,4 +7,18 @@ class Answer < ActiveRecord::Base
|
|||
def notification_type(*_args)
|
||||
Notifications::QuestionAnswered
|
||||
end
|
||||
|
||||
def remove
|
||||
self.user.decrement! :answered_count
|
||||
self.question.decrement! :answer_count
|
||||
self.smiles.each do |smile|
|
||||
Notification.denotify self.user, smile
|
||||
end
|
||||
self.comments.each do |comment|
|
||||
comment.user.decrement! :commented_count
|
||||
Notification.denotify self.user, comment
|
||||
end
|
||||
Notification.denotify self.question.user, self
|
||||
self.destroy
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue