Forum: Ruby on Rails how to convert a Hash to a URL parameter string??? (i.e. rea

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Greg H. (Guest)
on 2007-02-10 13:46
(Received via mailing list)

I've been trying to find out if there is already a Rails or Ruby method
convert a Hash to a URL parameter string?  Does one exist?

from      { "controller"=>"donate", "amt"=>"400.00" }
to          controller=donate&amt=400.00

i.e. ready to be appended to the end of a URI for a HTTP POST request

Russell N. (Guest)
on 2007-02-10 16:21
(Received via mailing list)
Just add them into the options for the url_for and you should be in
business. No need to do the conversion first. However, looking at your
example. It seems like donate should be a method of a controller and not
controller itself. You'd probably be better off with a Contributions
controller [which could provide an index of people who have donated
previously as well as other methods] and just using a CRUDdy new/create
of methodology. At any rate, adding :amt => "400.00" to the options
parameter in url_for will place amt as a parameter in the url.

Greg H. (Guest)
on 2007-02-10 21:47
(Received via mailing list)
My scenario was actually a manual HTTP request (see below).  I was
interested in whether there is an existing ruby or rails method to
the hash to a string (in the form of a URL parameter string)?  I know I
do this manually in ruby quite readily, but just very curious to know
whether there is a method already there to do it in one hit?

    postData = {"cc"=>"USD", "st"=>"Completed" }   #<=== Doesn't seem to
work, needs to be a string
    responseString = ""
    Net::HTTP.start(, uri.port) do |request|
        responseString =, postData).body

This topic is locked and can not be replied to.