Ruby url encoding string
Using ERB::Util.url_encode or CGI.escape. They primary difference between them is their handling of spaces:
>> ERB::Util.url_encode("foo/bar? baz&") => "foo%2Fbar%3F%20baz%26" >> CGI.escape("foo/bar? baz&") => "foo%2Fbar%3F+baz%26"
The CGI.escape gives you an application/x-www-form-urlencoded string requires spaces be escaped to +, whereas ERB::Util.url_encode. which requires them to be encoded as %20.