I’m positive this is a dupe, but I couldn’t find the original.
Given a GET-style string like foo=bar&x[0]=baz
, how can I decode this into a params
-like array in a Rails app?
Updated to add: Note that CGI.parse
seems to do much less than whatever magic Rails does:
1.9.3p194 :006 > CGI::parse 'foo=bar&x[foo][bar]=baz'
=> {"foo"=>["bar"], "x[foo][bar]"=>["baz"]}
CGI.parse didn’t unpack the nested objects into a mult-level hash. In Rails, at some level, this is actually examined.