use object instead of hash for displaying crops

This commit is contained in:
Brenda Wallace
2019-12-25 16:23:13 +13:00
parent ace0977c75
commit aea0d5877d
5 changed files with 9 additions and 24 deletions

View File

@@ -6,7 +6,7 @@
crop
.card-body
%h3.card-title
%strong= link_to crop, crop
%strong= link_to crop.name, crop_path(slug: crop.slug)
= crop.default_scientific_name
.d-flex.justify-content-between
- if crop.annual? && crop.median_lifespan.present?

View File

@@ -1,14 +0,0 @@
.card.crop-thumbnail
= link_to crop_path(slug: crop['slug']) do
= image_tag(crop['thumbnail_url'] ? crop['thumbnail_url'] : placeholder_image,
alt: crop['name'],
class: 'img img-card')
.text
%h3.crop-name
= link_to crop['name'], crop_path(slug: crop['slug'])
%h5.crop-sci-name
 
= crop['scientific_name']

View File

@@ -1,12 +1,11 @@
- cache crop do
.card.crop-thumbnail
= link_to image_tag(crop_image_path(crop),
= link_to image_tag(crop.thumbnail_url ? crop.thumbnail_url : placeholder_image,
alt: crop.name,
class: 'img img-card'),
crop
crop_path(slug: crop.slug)
.text
%h3.crop-name= link_to crop, crop
%h3.crop-name= link_to crop.name, crop_path(slug: crop.slug)
%h5.crop-sci-name
 
= crop.scientific_names.first&.name
= crop.scientific_names.first

View File

@@ -22,8 +22,8 @@
%h2= t('.title')
= will_paginate @crops
.index-cards
- @crops.each do |crop|
= render 'crops/search_result', crop: crop
- @crops.each do |c|
= render 'crops/thumbnail', crop: c
= will_paginate @crops

View File

@@ -1,4 +1,4 @@
- cache cache_key_for(Crop, 'homepage'), expires_in: 1.day do
.index-cards
- CropSearchService.random_with_photos(16).each do |crop|
= render 'crops/search_result', crop: crop
- CropSearchService.random_with_photos(16).each do |c|
= render 'crops/thumbnail', crop: c