Take the 2-minute tour ×

Not sure how to do this in Ruby/Rails only thing I could come up with is gsub. Which is giving me an undefined method.

What I am doing is via jQuery $.post is passing data to jRuby. My problem is, some browsers (most) are converting @ to %40, and , to %2C which is throwing a wrench in my works. So I want to catch specific ones to covert them to what they are supposed to be literally when "decoded".

I know this is a novice question, and I am almost positive the answer has to be on the web somewhere. But as I said I keep coming up on pages that suggest regex (which i want to avoid, and am not versed well with). Or others that suggest "gsub".

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Your string is URL encoded. Try to use CGI::unescape:

require 'cgi'
CGI::unescape('%40') # => "@"
share|improve this answer
add comment

Your Answer


