I am working on a web application where I have to encode and decode a string at the JavaScript side and Ruby backend of the code. the only problem is that the escape methods
Use
URI.escape(foo, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
in ruby, and
encodeURIComponent(foo);
in javascript
Both these will behave equally and encode space as %20.