Skip to content

Commit 6118350

Browse files
authored
Merge pull request #1612 from Growstuff/Br3nda-patch-1
Pick the first photo
2 parents bab4114 + 6c1bbe9 commit 6118350

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/helpers/photos_helper.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ def garden_image_path(garden)
1717

1818
def planting_image_path(planting)
1919
if planting.photos.present?
20-
planting.photos.first.thumbnail_url
20+
planting.photos.order(date_taken: :desc).first.thumbnail_url
2121
else
2222
placeholder_image
2323
end
2424
end
2525

2626
def harvest_image_path(harvest)
2727
if harvest.photos.present?
28-
harvest.photos.first.thumbnail_url
29-
elsif harvest.planting.present? && harvest.planting.photos.present?
30-
harvest.planting.photos.first.thumbnail_url
28+
harvest.photos.order(date_taken: :desc).first.thumbnail_url
29+
elsif harvest.planting.present?
30+
planting_image_path(harvest.planting)
3131
else
3232
placeholder_image
3333
end

0 commit comments

Comments
 (0)