public Method

Route.build_query_string(hash, only_keys = nil)

Build a query string from the keys of the given hash. If only_keys is given (as an array), only the keys indicated will be used to build the query string. The query string will correctly build array parameter values.

Source Code

# File action_controller/routing/route.rb, line 152
def build_query_string(hash, only_keys = nil)
  elements = []

  (only_keys || hash.keys).each do |key|
    if value = hash[key]
      elements << value.to_query(key)
    end
  end

  elements.empty? ? '' : "?#{elements.sort * '&'}"
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.