From b4cfc95c835af8000bf0f90c414e58f26e3a14bc Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Tue, 19 Mar 2024 22:05:45 +0100 Subject: [PATCH] Adjust accessors to pull values from attributes if they exist This has to be done because using multiple queries in a select statement does not automatically map into an ActiveRecord model and the values we want wait in the `self.attributes` hash. --- app/models/answer.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/answer.rb b/app/models/answer.rb index 5abd6d5a..750009cf 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -71,4 +71,8 @@ class Answer < ApplicationRecord def long? = content.length > SHORT_ANSWER_MAX_LENGTH def pinned? = pinned_at.present? + + def has_reacted = self.attributes["has_reacted"] || false + + def is_subscribed = self.attributes["is_subscribed"] || false end