Module: Care::AutoFinder::Sortable
- Defined in:
- lib/care/auto_finder/sortable.rb
Overview
Содержит методы для сортировки коллекции
Instance Method Summary collapse
-
#sort(items) ⇒ Object
def sort(items) params.present? ? items.order(order_expiration) : items.order(created_at: :asc) end.
Instance Method Details
#sort(items) ⇒ Object
def sort(items)
params[:sort].present? ? items.order(order_expiration) : items.order(created_at: :asc)
end
24 25 26 27 28 29 30 31 32 |
# File 'lib/care/auto_finder/sortable.rb', line 24 def sort(items) if params[:sort].present? items.order(order_expiration) elsif items.methods.include?(:default_sort) items.default_sort else items.order(created_at: :asc) end end |