From d7997db4920e88b2b7bb0f5675349402d488da4e Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Fri, 17 Feb 2023 00:45:40 +0100 Subject: [PATCH] Check subscription in `answer/show` --- app/controllers/answer_controller.rb | 1 + app/views/answer/show.html.haml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/answer_controller.rb b/app/controllers/answer_controller.rb index d5e70881..110486d1 100644 --- a/app/controllers/answer_controller.rb +++ b/app/controllers/answer_controller.rb @@ -9,6 +9,7 @@ class AnswerController < ApplicationController def show @answer = Answer.includes(comments: %i[user smiles], question: [:user], smiles: [:user]).find(params[:id]) + @subscribed = Subscription.where(user: current_user, answer: @answer).pluck(:id) @display_all = true if user_signed_in? diff --git a/app/views/answer/show.html.haml b/app/views/answer/show.html.haml index 5f84d47d..393b0dd5 100644 --- a/app/views/answer/show.html.haml +++ b/app/views/answer/show.html.haml @@ -1,4 +1,4 @@ - provide(:title, answer_title(@answer)) - provide(:og, answer_opengraph(@answer)) .container-lg.container--main - = render 'answerbox', a: @answer, display_all: @display_all + = render 'answerbox', a: @answer, display_all: @display_all, subscribed_answer_ids: @subscribed