From: "Mark J. Reed" Date: 2003-07-21T06:37:24+09:00 Subject: Re: Parsing POST and GET variables simultaneously? Eep! Holy Wrong Newsgroup, Batman! It did include the stuff that was meant to go here, though, which I hereby cut to. Sorry about that. On Mon, Jul 21, 2003 at 02:47:37AM +0900, David Heinemeier Hansson wrote: > class CGI > def query_params > params = {} > > ENV['QUERY_STRING'].split("&").each { |p| > k, v = p.split("=") > params[CGI.unescape(k)] = CGI.unescape(v) > } > > params > end > end > > ..that does the trick. God, I love Ruby. May I never stray back into > PHP-land again :) May your wish come true. :) And that solution will indeed work most of the time. However, to be perfectly compliant with modern protocols, you need to split on either '&' or ';'. And it'd be better to use the query_string method than to directly access the environment variable: class CGI def query_params params = {} query_string.split(/[&;]/).each { |p| k, v = p.split('=') params[CGI.unescape(k)] = CGI.unescape(v) } params end end -Mark