Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use reorder instead of order to override default_scope order. #89

Open
wants to merge 1 commit into from

1 participant

@webervin

Only other way to override default scope order AND keep power of meta_search ordering would be:
ModelClass.reorder(true).search(.....) which seems a bit awful to me, and may explode for some databases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/meta_search/builder.rb
View
4 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
Something went wrong with that request. Please try again.