2014-12-04 22:02:23 -08:00
|
|
|
class AnswerController < ApplicationController
|
|
|
|
def show
|
|
|
|
@answer = Answer.find(params[:id])
|
2014-12-12 09:54:17 -08:00
|
|
|
@display_all = true
|
2015-02-09 21:53:50 -08:00
|
|
|
|
|
|
|
if user_signed_in?
|
|
|
|
notif = Notification.where(target_type: "Answer", target_id: @answer.id, recipient_id: current_user.id, new: true).first
|
|
|
|
unless notif.nil?
|
|
|
|
notif.new = false
|
|
|
|
notif.save
|
|
|
|
end
|
2015-02-12 08:48:46 -08:00
|
|
|
notif = Notification.where(target_type: "Comment", target_id: @answer.comments.pluck(:id), recipient_id: current_user.id, new: true)
|
|
|
|
notif.update_all(new: false) unless notif.empty?
|
|
|
|
notif = Notification.where(target_type: "Smile", target_id: @answer.smiles.pluck(:id), recipient_id: current_user.id, new: true)
|
|
|
|
notif.update_all(new: false) unless notif.empty?
|
2015-05-04 14:06:57 -07:00
|
|
|
# @answer.comments.smiles throws
|
|
|
|
notif = Notification.where(target_type: "CommentSmile", target_id: @answer.comment_smiles.pluck(:id), recipient_id: current_user.id, new: true)
|
|
|
|
notif.update_all(new: false) unless notif.empty?
|
2015-02-09 21:53:50 -08:00
|
|
|
end
|
2014-12-04 22:02:23 -08:00
|
|
|
end
|
|
|
|
end
|