Skip to content

Commit 0c2a8bf

Browse files
committed
reuse existing attribute value query in serializer
1 parent 765ec3c commit 0c2a8bf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/models/serializers/content_serializer.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ def initialize(content)
113113
def value_for(attribute_field, content)
114114
case attribute_field.field_type
115115
when 'link'
116-
page_links = attribute_field.attribute_values.find_by(entity_type: content.class.name, entity_id: content.id)
116+
page_links = self.attribute_values.detect do |value|
117+
value.entity_type == content.class.name && value.entity_id == content.id && value.attribute_field_id == attribute_field.id
118+
end
117119
if page_links.nil?
118120
# Fall back on old relation value
119121
# We're technically doing a double lookup here (by converting response

0 commit comments

Comments
 (0)