mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-19 03:56:06 +01:00
moved some code
This commit is contained in:
parent
6d81b4a24b
commit
b6c0b1864a
2 changed files with 15 additions and 4 deletions
|
@ -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 a new issue