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.
This commit is contained in:
Andreas Nedbal 2024-03-19 22:05:45 +01:00 committed by Andreas Nedbal
parent 997953565f
commit b4cfc95c83
1 changed files with 4 additions and 0 deletions

View File

@ -71,4 +71,8 @@ class Answer < ApplicationRecord
def long? = content.length > SHORT_ANSWER_MAX_LENGTH def long? = content.length > SHORT_ANSWER_MAX_LENGTH
def pinned? = pinned_at.present? def pinned? = pinned_at.present?
def has_reacted = self.attributes["has_reacted"] || false
def is_subscribed = self.attributes["is_subscribed"] || false
end end