diff --git a/lib/meta_search/builder.rb b/lib/meta_search/builder.rb index 024a080..d1dbf20 100644 --- a/lib/meta_search/builder.rb +++ b/lib/meta_search/builder.rb @@ -169,14 +169,14 @@ def set_sort(val) @relation = @relation.send("sort_by_#{column}_#{direction}") elsif attribute = get_attribute(column) search_attributes['meta_sort'] = val - @relation = @relation.order(attribute.send(direction).to_sql) + @relation = @relation.reorder(attribute.send(direction).to_sql) elsif column.scan('_and_').present? attribute_names = column.split('_and_') attributes = attribute_names.map {|n| get_attribute(n)} if attribute_names.size == attributes.compact.size # We found all attributes search_attributes['meta_sort'] = val attributes.each do |attribute| - @relation = @relation.order(attribute.send(direction).to_sql) + @relation = @relation.reorder(attribute.send(direction).to_sql) end end end