Skip to content

Commit b24992b

Browse files
committed
Only check the protip kind if it's present on the protip
1 parent 1333720 commit b24992b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/models/protip.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,13 @@ def images
782782
if self.new_record?
783783
self.links.select { |link| ProtipLink.is_image? link }
784784
else
785-
protip_links.loaded? ? protip_links.select { |p| ProtipLink::IMAGE_KINDS.include?(p.kind.to_sym) }.map(&:url) : protip_links.where('kind in (?)', ProtipLink::IMAGE_KINDS).map(&:url)
785+
if protip_links.loaded?
786+
protip_links.select do |p|
787+
ProtipLink::IMAGE_KINDS.include?(p.kind.to_sym) if p.kind
788+
end.map(&:url).compact
789+
else
790+
protip_links.where('kind in (?)', ProtipLink::IMAGE_KINDS).map(&:url)
791+
end
786792
end
787793
end
788794

0 commit comments

Comments
 (0)