Retrospring/app/controllers/answer_controller.rb

18 lines
1.0 KiB
Ruby
Raw Normal View History

2014-12-04 22:02:23 -08:00
class AnswerController < ApplicationController
def show
@answer = Answer.includes(comments: [:user, :smiles], question: [:user], smiles: [:user]).find(params[:id])
2014-12-12 09:54:17 -08:00
@display_all = true
if user_signed_in?
notif = Notification.where(type: "Notification::QuestionAnswered", target_id: @answer.id, recipient_id: current_user.id, new: true).first
notif.update(new: false) unless notif.nil?
notif = Notification.where(type: "Notification::Commented", target_id: @answer.comments.pluck(:id), recipient_id: current_user.id, new: true)
notif.update_all(new: false) unless notif.empty?
notif = Notification.where(type: "Notification::Smiled", target_id: @answer.smiles.pluck(:id), recipient_id: current_user.id, new: true)
notif.update_all(new: false) unless notif.empty?
notif = Notification.where(type: "Notification::CommentSmiled", target_id: @answer.comment_smiles.pluck(:id), recipient_id: current_user.id, new: true)
2015-05-04 14:06:57 -07:00
notif.update_all(new: false) unless notif.empty?
end
2014-12-04 22:02:23 -08:00
end
end