Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Additional parameters can be added to url generated with order helper

Signed-off-by: Ben Johnson <bjohnson@binarylogic.com>
  • Loading branch information...
commit eba965eb8367097611dd723064013a6ff46d94ad 1 parent bc41b84
kazjote authored committed
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/searchlogic/rails_helpers.rb
8 lib/searchlogic/rails_helpers.rb
View
@@ -17,6 +17,7 @@ module RailsHelpers
# * <tt>:as</tt> - the text used in the link, defaults to whatever is passed to :by
# * <tt>:ascend_scope</tt> - what scope to call for ascending the data, defaults to "ascend_by_:by"
# * <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
@@ -37,7 +38,10 @@ def order(search, options = {}, html_options = {})
end
html_options[:class] = css_classes.join(" ")
end
- link_to options[:as], url_for(options[:params_scope] => search.conditions.merge( { :order => new_scope } ) ), html_options
+ url_options = {
+ 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
@@ -66,4 +70,4 @@ def fields_for(*args, &block)
end
end
end
-end
+end

1 comment on commit eba965e

Georg Ledermann

Very useful, thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.