Fix `has_reacted` and `is_subscribed` not being set

This commit is contained in:
Karina Kwiatek 2023-12-18 18:28:19 +01:00
parent 52e17d0f68
commit 539868173c
3 changed files with 2 additions and 5 deletions

View File

@ -44,9 +44,6 @@ class Ajax::AnswerController < AjaxController
return if inbox
# 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 })
end

View File

@ -1,7 +1,7 @@
class Answer < ApplicationRecord
extend Answer::TimelineMethods
attr_accessor :has_reacted, :is_subscribed
attr_writer :has_reacted, :is_subscribed
belongs_to :user, counter_cache: :answered_count
belongs_to :question, counter_cache: :answer_count

View File

@ -122,7 +122,7 @@ class User < ApplicationRecord
Retrospring::Metrics::QUESTIONS_ANSWERED.increment
Answer.create!(content:, user: self, question:)
Answer.create!(content:, user: self, question:, has_reacted: false, is_subscribed: true)
end
# has the user answered +question+ yet?