mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-09 16:24:32 -04:00
@@ -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
|
||||
|
||||
@@ -43,7 +43,7 @@ class Post < ActiveRecord::Base
|
||||
|
||||
# return posts sorted by recent activity
|
||||
def self.recently_active
|
||||
Post.all.sort do |a, b|
|
||||
Post.order(created_at: :desc).sort do |a, b|
|
||||
b.recent_activity <=> a.recent_activity
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
- posts = Post.limit(6)
|
||||
- if posts
|
||||
= render partial: "posts/summary", locals: { posts: posts, howmany: 6 }
|
||||
= render "posts/summary", posts: posts, howmany: 6
|
||||
|
||||
- cache cache_key_for(Forum) do
|
||||
- forums = Forum.all.order(:name)
|
||||
|
||||
Reference in New Issue
Block a user