Add order on topic index.

This commit is contained in:
taitus
2017-08-07 18:56:04 +02:00
parent 1dc3cd4bb3
commit a1d37fa6c4
3 changed files with 15 additions and 21 deletions

View File

@@ -9,6 +9,10 @@ class Topic < ActiveRecord::Base
after_create :associate_comment
scope :sort_by_newest, -> { order(created_at: :desc) }
scope :sort_by_oldest, -> { order(created_at: :asc) }
scope :sort_by_most_commented, -> { reorder(comments_count: :desc) }
private
def associate_comment