How do I URL-escape a string in Rails?

后端 未结 4 1539
心在旅途
心在旅途 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:46

    CGI.escape will do it:

    <% redirect_href = "/redirect?#{CGI.escape target}&foo=bar&baz=some_other_stuff" -%>
    Foo
    

提交回复
热议问题