Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/meta_search/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down