debian-mirror-gitlab/app/models/concerns/sortable_title.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
506 B
Ruby
Raw Normal View History

2021-11-11 11:23:49 +05:30
# frozen_string_literal: true
module SortableTitle
extend ActiveSupport::Concern
included do
scope :order_title_asc, -> { reorder(Arel::Nodes::Ascending.new(arel_table[:title].lower)) }
scope :order_title_desc, -> { reorder(Arel::Nodes::Descending.new(arel_table[:title].lower)) }
end
class_methods do
def simple_sorts
super.merge(
{
'title_asc' => -> { order_title_asc },
'title_desc' => -> { order_title_desc }
}
)
end
end
end