diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-12 16:30:39 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-18 13:05:45 +0100 |
commit | 656d9ff69b372be8e0aebb94418c487e76e04256 (patch) | |
tree | 919fd6f37ac5d8f0d9876c9a9bdff23cf440831e /app | |
parent | 028bd227fb1915edca181331542c433fd171d31a (diff) | |
download | gitlab-ce-656d9ff69b372be8e0aebb94418c487e76e04256.tar.gz |
Make it easier to re-apply default sort orders
By moving the default sort order into a separate scope (and calling this
from the default scope) we can more easily re-apply a default order
without having to specify the exact column/ordering all over the place.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/sortable.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb index 913c747a1c3..7391a77383c 100644 --- a/app/models/concerns/sortable.rb +++ b/app/models/concerns/sortable.rb @@ -8,8 +8,9 @@ module Sortable included do # By default all models should be ordered # by created_at field starting from newest - default_scope { order(id: :desc) } + default_scope { order_id_desc } + scope :order_id_desc, -> { reorder(id: :desc) } scope :order_created_desc, -> { reorder(created_at: :desc) } scope :order_created_asc, -> { reorder(created_at: :asc) } scope :order_updated_desc, -> { reorder(updated_at: :desc) } |