adds random order to debates' index

This commit is contained in:
Juanjo Bazán
2015-09-03 18:50:19 +02:00
parent dbfa35c444
commit 559b60e63f
5 changed files with 24 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ class Debate < ActiveRecord::Base
scope :sort_by_score , -> { reorder(cached_votes_score: :desc) }
scope :sort_by_created_at, -> { reorder(created_at: :desc) }
scope :sort_by_most_commented, -> { reorder(comments_count: :desc) }
scope :sort_by_random, -> { reorder("RANDOM()") }
# Ahoy setup
visitable # Ahoy will automatically assign visit_id on create