Module: Sortable::ClassMethods

Defined in:
app/models/concerns/sortable.rb

Instance Method Summary collapse

Instance Method Details

#order_by(method) ⇒ Object


24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/concerns/sortable.rb', line 24

def order_by(method)
  case method.to_s
  when 'name_asc' then order_name_asc
  when 'name_desc' then order_name_desc
  when 'updated_asc' then order_updated_asc
  when 'updated_desc' then order_updated_desc
  when 'created_asc' then order_created_asc
  when 'created_desc' then order_created_desc
  when 'id_desc' then order_id_desc
  when 'id_asc' then order_id_asc
  else
    all
  end
end