CGI.escape will do it:
<% redirect_href = "/redirect?#{CGI.escape target}&foo=bar&baz=some_other_stuff" -%>
<a href="<%= redirect_href =>">Foo</a>
CGI.escape will do it:
<% redirect_href = "/redirect?#{CGI.escape target}&foo=bar&baz=some_other_stuff" -%>
<a href="<%= redirect_href =>">Foo</a>