Rename allowed sort option variable

This commit is contained in:
Anna Anks Nowak
2019-01-01 19:54:39 +01:00
committed by Javi Martín
parent 39cc997ef4
commit 101292d303

View File

@@ -141,11 +141,11 @@ class Budget
def self.order_filter(sorting_param, direction)
sorting_key = sorting_param.to_sym if sorting_param
available_option = SORTING_OPTIONS.select { |sp| sp[sorting_key]}.reduce
allowed_sort_option = SORTING_OPTIONS.select { |sp| sp[sorting_key]}.reduce
if sorting_param.present? && available_option.present? then
if sorting_param.present? && allowed_sort_option.present? then
direction = %w[asc desc].include?(direction) ? direction : "asc"
order("#{available_option[sorting_key]} #{direction}")
order("#{allowed_sort_option[sorting_key]} #{direction}")
else
order(cached_votes_up: :desc).order(id: :desc)
end