Skip to content

Instantly share code, notes, and snippets.

@dennisfaust
Last active August 29, 2015 14:03
Show Gist options
  • Save dennisfaust/d657f130c0fe1865ac9b to your computer and use it in GitHub Desktop.
Save dennisfaust/d657f130c0fe1865ac9b to your computer and use it in GitHub Desktop.
Query String, Hash and Params back and forth...
# To and from hash and params (Rails 4)
str = 'nonce=2147483647&version=2.0&client_id=8iR5q'
h = Rack::Utils.parse_query str
params = ActiveSupport::HashWithIndifferentAccess.new(h)
# back to string:
query_str = params.to_query
Rack::Utils.parse_query(query_str) == Rack::Utils.parse_query(str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment