lib/searchlogic/rails_helpers.rb in binarylogic-searchlogic-2.2.3 vs lib/searchlogic/rails_helpers.rb in binarylogic-searchlogic-2.3.0

- old
+ new

@@ -19,10 +19,13 @@ # * <tt>:descend_scope</tt> - what scope to call for descending the data, defaults to "descend_by_:by" # * <tt>:params</tt> - hash with additional params which will be added to generated url # * <tt>:params_scope</tt> - the name of the params key to scope the order condition by, defaults to :search def order(search, options = {}, html_options = {}) options[:params_scope] ||= :search - options[:as] ||= options[:by].to_s.humanize + if !options[:as] + id = options[:by].to_s.downcase == "id" + options[:as] = id ? options[:by].to_s.upcase : options[:by].to_s.humanize + end options[:ascend_scope] ||= "ascend_by_#{options[:by]}" options[:descend_scope] ||= "descend_by_#{options[:by]}" 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.to_s)