Topic: method for hash to name value pairs

Does any one know how to convert an hash into name value pairs ( CGI style) as below:
input:
my_hash = {
             :amount => params[:amount],
             :first_name => params[:firstName],
             Etc...
             }

output:
name1=value1&name2=value2&name3=value3................&namen=valuen

Re: method for hash to name value pairs

Try this:

hash.to_a.map { |a| a.join('=') }.join('&')

There might be an easier way.

Railscasts - Free Ruby on Rails Screencasts

Re: method for hash to name value pairs

that worked for me- thanks