simplify method

pull/5981/head
Jens Ulferts 7 years ago
parent 0f9313dd26
commit ee343e3e40
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 12
      app/helpers/sort_helper.rb

@ -106,9 +106,9 @@ module SortHelper
def to_param(format = nil) def to_param(format = nil)
if format == :json if format == :json
JSON::dump(@criteria.map { |k, o| [k, o ? 'asc' : 'desc'] }) to_json_param
else else
@criteria.map { |k, o| k + (o ? '' : ':desc') }.join(',') to_sort_param
end end
end end
@ -170,6 +170,14 @@ module SortHelper
"#{criterion} DESC" "#{criterion} DESC"
end end
end end
def to_json_param
JSON::dump(@criteria.map { |k, o| [k, o ? 'asc' : 'desc'] })
end
def to_sort_param
@criteria.map { |k, o| k + (o ? '' : ':desc') }.join(',')
end
end end
def sort_name def sort_name

Loading…
Cancel
Save