Growstuff/growstuff

View on GitHub
app/views/crops/_photos.html.haml

Summary

Maintainability
Test Coverage
%h2 #{photo_icon} Photos
- [Crop, Planting, Harvest, Seed].each do |model_name|
  - if crop.photos.by_model(model_name).any?
    %h3 #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")}
    = render 'photos/gallery', photos: crop.photos.by_model(model_name).includes(:owner).order(likes_count: :desc).limit(5)
- if crop.photos.count.positive?
  = link_to 'more photos ยป', crop_photos_path(@crop), class: 'btn'