lib/searchlogic/rails_helpers.rb in kazjote-searchlogic-2.1.9.1 vs lib/searchlogic/rails_helpers.rb in kazjote-searchlogic-2.1.9.3
- old
+ new
@@ -21,13 +21,13 @@
def order(search, options = {}, html_options = {})
options[:params_scope] ||= :search
options[:as] ||= options[:by].to_s.humanize
options[:ascend_scope] ||= "ascend_by_#{options[:by]}"
options[:descend_scope] ||= "descend_by_#{options[:by]}"
- ascending = search.order_by.to_s == options[:ascend_scope]
+ ascending = search.order.to_s == options[:ascend_scope]
new_scope = ascending ? options[:descend_scope] : options[:ascend_scope]
- selected = [options[:ascend_scope], options[:descend_scope]].include?(search.order_by.to_s)
+ selected = [options[:ascend_scope], options[:descend_scope]].include?(search.order.to_s)
if selected
css_classes = html_options[:class] ? html_options[:class].split(" ") : []
if ascending
options[:as] = "▲ #{options[:as]}"
css_classes << "ascending"
@@ -36,11 +36,11 @@
css_classes << "descending"
end
html_options[:class] = css_classes.join(" ")
end
url_options = {
- options[:params_scope] => search.conditions.merge( { :order_by => new_scope } )
+ options[:params_scope] => search.conditions.merge( { :order => new_scope } )
}.deep_merge(options[:params] || {})
link_to options[:as], url_for(url_options), html_options
end
# Automatically makes the form method :get if a Searchlogic::Search and sets
@@ -60,10 +60,10 @@
# Automatically adds an "order" hidden field in your form to preserve how the data
# is being ordered.
def fields_for(*args, &block)
if search_obj = args.find { |arg| arg.is_a?(Searchlogic::Search) }
args.unshift(:search) if args.first == search_obj
- concat(content_tag("div", hidden_field_tag("#{args.first}[order_by]", search_obj.order)) + "\n")
+ concat(content_tag("div", hidden_field_tag("#{args.first}[order]", search_obj.order)) + "\n")
super
else
super
end
end