How do I URL-escape a string in Rails?

后端 未结 4 1542
心在旅途
心在旅途 2020-12-08 08:52

If I\'m in an RHTML view in Rails, it is easy to URL-escape something:

\">Foo

4条回答
  •  轮回少年
    2020-12-08 09:38

    Use either CGI::escape or ERB::Util.url_encode but not URI.encode.

    URI.escape has been deprecated circa Ruby 1.9.2: What's the difference between URI.escape and CGI.escape?

提交回复
热议问题