From 13d69cfd432335e0679a5eabbdaa7311d54e0caf Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 9 Dec 2023 18:05:50 +0100 Subject: [PATCH] Fix render error on answer create --- app/controllers/ajax/answer_controller.rb | 6 ++++-- app/models/answer.rb | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/ajax/answer_controller.rb b/app/controllers/ajax/answer_controller.rb index 65f8f29d..95651568 100644 --- a/app/controllers/ajax/answer_controller.rb +++ b/app/controllers/ajax/answer_controller.rb @@ -44,9 +44,11 @@ class Ajax::AnswerController < AjaxController return if inbox - # this assign is needed because shared/_answerbox relies on it, I think + # these assigns are needed because shared/_answerbox rely on them + answer.has_reacted = false + answer.is_subscribed = false @question = 1 - @response[:render] = render_to_string(partial: "answerbox", locals: { a: answer, show_question: false, subscribed_answer_ids: [answer.id] }) + @response[:render] = render_to_string(partial: "answerbox", locals: { a: answer, show_question: false }) end def destroy diff --git a/app/models/answer.rb b/app/models/answer.rb index e115e9a1..f13880f9 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -1,6 +1,8 @@ class Answer < ApplicationRecord extend Answer::TimelineMethods + attr_accessor :has_reacted, :is_subscribed + belongs_to :user, counter_cache: :answered_count belongs_to :question, counter_cache: :answer_count has_many :comments, dependent: :destroy