#840 Eager load photos

This commit is contained in:
Daniel O'Connor committed 2016-03-28 23:08:26 +10:30
1 parent f23cb78dcb
commit b57cb581dd
1 file changed
+1 -1
+1 -1
View File
@@ -116,7 +116,7 @@ class Planting < ActiveRecord::Base
interesting_plantings = Array.new
seen_owners = Hash.new(false) # keep track of which owners we've seen already
Planting.all.each do |p|
Planting.includes(:photos).each do |p|
break if interesting_plantings.size == howmany # got enough yet?
if require_photo
next unless p.photos.present? # skip those without photos, if required