From 822b2c728e3068831749f9bb5004654afed32843 Mon Sep 17 00:00:00 2001 From: kikito Date: Sun, 13 Sep 2015 20:27:58 +0200 Subject: [PATCH] Adds a new sort scope for proposals --- app/models/proposal.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 5b9ad5169..ab31a8b70 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -30,6 +30,7 @@ class Proposal < ActiveRecord::Base scope :sort_by_created_at, -> { order(created_at: :desc) } scope :sort_by_most_commented, -> { order(comments_count: :desc) } scope :sort_by_random, -> { order("RANDOM()") } + scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } def total_votes cached_votes_up