From f27ac12563c50ffcb5a69a2e77a7c853fd7e68e6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 2 Jan 2020 20:29:41 +1300 Subject: [PATCH] don't pass photos to crops/_photos --- app/views/crops/_photos.html.haml | 6 +++--- app/views/crops/show.html.haml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index ba27113f6..207974b0a 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,7 +1,7 @@ -- if photos.size.positive? +- if crop.photo_associations_count.positive? %h2 #{photo_icon} Photos - [Crop, Planting, Harvest, Seed].each do |model_name| - - if photos.by_model(model_name).size.positive? + - if crop.photos.by_model(model_name).size.positive? %h3 #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} - = render 'photos/gallery', photos: photos.by_model(model_name).includes(:owner).order(likes_count: :desc).limit(5) + = render 'photos/gallery', photos: crop.photos.by_model(model_name).includes(:owner).order(likes_count: :desc).limit(5) = link_to 'more photos ยป', crop_photos_path(@crop), class: 'btn' diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 7acefc6bb..f4dd34744 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -32,7 +32,7 @@ %section.photos = cute_icon - = render 'crops/photos', photos: @photos, crop: @crop + = render 'crops/photos', crop: @crop - if @crop.plantings.any? %section.charts