lib/ransack/nodes/sort.rb in ransack-1.1.0 vs lib/ransack/nodes/sort.rb in ransack-1.2.0

- old
+ new

@@ -7,11 +7,11 @@ i18n_word :asc, :desc class << self def extract(context, str) attr, direction = str.split(/\s+/,2) - self.new(context).build(:name => attr, :dir => direction) + self.new(context).build(name: attr, dir: direction) end end def build(params) params.with_indifferent_access.each do |key, value| @@ -22,11 +22,13 @@ self end def valid? - bound? && attr + bound? && attr && + context.klassify(parent).ransortable_attributes(context.auth_object) + .include?(attr_name) end def name=(name) @name = name context.bind(self, name) unless name.blank? @@ -37,6 +39,6 @@ @dir = %w(asc desc).include?(dir) ? dir : 'asc' end end end -end \ No newline at end of file +end