Forum: Ruby on Rails URL encode & decode

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Li Jie (Guest)
on 2006-04-20 06:35
(Received via mailing list)
I have a link:
<%= link_to 'delete', :action => 'destroy', :id => u(string_id) %>

Helper method 'u()' can encode a string to URL encoding, but I don't
know which method can decode it? I  want to used in controller. I have
not seen it in Rails's document.

Thanks,

- Li Jie
Justin F. (Guest)
on 2006-04-22 17:53
(Received via mailing list)
Li Jie wrote:
> I have a link:
> <%= link_to 'delete', :action => 'destroy', :id => u(string_id) %>
>
> Helper method 'u()' can encode a string to URL encoding, but I don't
> know which method can decode it? I  want to used in controller. I have
> not seen it in Rails's document.

---------------------------------------------------------- CGI::unescape
      CGI::unescape(string)
------------------------------------------------------------------------
      URL-decode a string.

        string = CGI::unescape("%27Stop%21%27+said+Fred")
           # => "'Stop!' said Fred"

(you will need

   require 'cgi'

in your controller)

regards

   Justin
This topic is locked and can not be replied to.