From 95a923ff5f88922b4d350e651cb570843ff2e7bb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 15 Dec 2017 13:26:48 +1300 Subject: [PATCH] Order the plantings on the front page --- app/models/planting.rb | 1 + app/views/home/_crops.html.haml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/planting.rb b/app/models/planting.rb index 85e5277c0..c51166264 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -26,6 +26,7 @@ class Planting < ActiveRecord::Base scope :finished, -> { where(finished: true) } scope :current, -> { where(finished: false) } scope :interesting, -> { has_photos.one_per_owner } + scope :recent, -> { order(created_at: :desc) } scope :one_per_owner, lambda { joins("JOIN members m ON (m.id=plantings.owner_id) LEFT OUTER JOIN plantings p2 diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index 274cd4957..6f881dc32 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -14,7 +14,7 @@ .col-md-4.hidden-xs - cache cache_key_for(Planting) do %h2= t('.recently_planted') - = render partial: 'plantings/list', locals: { plantings: Planting.includes(:owner, :photos).interesting.first(6) } + = render 'plantings/list', plantings: Planting.includes(:owner, :photos).interesting.recent.first(6) .row .col-md-12