Last active
August 29, 2015 14:03
-
-
Save dennisfaust/d657f130c0fe1865ac9b to your computer and use it in GitHub Desktop.
Query String, Hash and Params back and forth...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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