diff --git a/lib/ransack/constants.rb b/lib/ransack/constants.rb index de6ac40..6fe57ca 100644 --- a/lib/ransack/constants.rb +++ b/lib/ransack/constants.rb @@ -27,6 +27,7 @@ module Ransack FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].to_set BOOLEAN_VALUES = TRUE_VALUES + FALSE_VALUES + S_SORTS = %w(s sorts).freeze ASC_DESC = %w(asc desc).freeze AND_OR = %w(and or).freeze IN_NOT_IN = %w(in not_in).freeze diff --git a/lib/ransack/search.rb b/lib/ransack/search.rb index 64d712f..34dde54 100644 --- a/lib/ransack/search.rb +++ b/lib/ransack/search.rb @@ -36,7 +36,7 @@ module Ransack def build(params) collapse_multiparameter_attributes!(params).each do |key, value| - if ['s', 'sorts'].include?(key) + if Ransack::Constants::S_SORTS.include?(key) send("#{key}=", value) elsif base.attribute_method?(key) base.send("#{key}=", value)