Is there an equivalent to PHP’s urlencode in Ruby on Rails 2.3.5? (It encodes a string to be used in a query part of a URL)
I googled it but all the answers seem to date back to before 2006 and seems dates.
This is what I found. It seems a bit abnormal to call CGI::escape in a view.
Is there an equivalent helper function?
Thanks!
I believe the
uhelper method is what you’re looking for:This uses the
method ERB::Util.url_encode,which is aliased tou.You can find the documentation for this method here: http://rdoc.info/stdlib/erb/1.8.7/ERB/Util:url_encode.