From: saurabh purnaye Date: 2009-09-15T12:21:17+09:00 Subject: Re: URL format --0016e64cb30466e2fc047395469a Content-Type: text/plain; charset=ISO-8859-1 Hi, I think I had faced the same issue before for encoding, I have used this method for encoding urls. require 'rubygems' require 'rest-open-uri' require 'uri' require 'cgi' def form_encoded(hash) encoded = [] hash.each do |key, value| encoded << CGI.escape(key) + '=' + CGI.escape(value) end return encoded.join('&') end representation = form_encoded({ "user[name]" => username, "user[password]" => password, "user[full_name]" => full_name, "user[email]" => email }) hope it will work for you... -- -- Thanks and Regards Saurabh Purnaye +91-9922071155 skype: sorab_pune yahoo & gtalk: saurabh.purnaye msn: psaurabh@live.com -- Please don't print this e-mail unless you really need to. On Tue, Sep 15, 2009 at 8:44 AM, Bertram Scharpf wrote: > Hi, > > Am Dienstag, 15. Sep 2009, 10:32:24 +0900 schrieb John W Higgins: > > On Mon, Sep 14, 2009 at 5:58 PM, Re BR wrote: > > > I have the following hash myhash > > > { "inter" => "team", "shirt" => "stripe" } > > > > > > desired output > > > > > > inter=team&shirt=stripe > > > > The single line answer would be > > > > hsh = { "inter" => "team", "shirt" => "stripe" } > > hsh.to_a.map{|e| e.join('=')}.join('&') # 'inter=team&shirt=stripe' > > The correct way escapes the `=' and `&' signs. I wrote my own > library and it seems that it doesn't. Ugh. > > Bertram > > > -- > Bertram Scharpf > Stuttgart, Deutschland/Germany > http://www.bertram-scharpf.de > > --0016e64cb30466e2fc047395469a--