mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-19 07:36:03 +01:00
28 lines
709 B
Ruby
28 lines
709 B
Ruby
class Ajax::AnswerController < ApplicationController
|
|
def destroy
|
|
params.require :answer
|
|
|
|
unless current_user.nil?
|
|
current_user.increment! :asked_count unless params[:anonymousQuestion] == 'true'
|
|
end
|
|
|
|
answer = Answer.find(params[:answer])
|
|
|
|
puts ">>>>>>>>>>>>", privileged?.inspect
|
|
|
|
unless answer.user == current_user || privileged?
|
|
@status = :nopriv
|
|
@message = "check yuor privlegs"
|
|
@success = false
|
|
return
|
|
end
|
|
|
|
answer.user.decrement! :answered_count
|
|
Inbox.create!(user: answer.user, question: answer.question, new: true)
|
|
answer.destroy
|
|
|
|
@status = :okay
|
|
@message = "Successfully deleted answer."
|
|
@success = true
|
|
end
|
|
end
|