From 998c2021b3b582dccea060467b80c35626b6f786 Mon Sep 17 00:00:00 2001 From: Mike Hall Date: Mon, 6 Oct 2014 11:51:54 -0500 Subject: [PATCH] Only check the protip kind if it's present on the protip --- app/models/protip.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/protip.rb b/app/models/protip.rb index 71836531..33f61265 100644 --- a/app/models/protip.rb +++ b/app/models/protip.rb @@ -782,7 +782,13 @@ def images if self.new_record? self.links.select { |link| ProtipLink.is_image? link } else - 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) + if protip_links.loaded? + protip_links.select do |p| + ProtipLink::IMAGE_KINDS.include?(p.kind.to_sym) if p.kind + end.map(&:url).compact + else + protip_links.where('kind in (?)', ProtipLink::IMAGE_KINDS).map(&:url) + end end end