link_to and GET parameters

Hi, I am trying to generate a link to external site with GET parameters ( in new window). I tried following code, but it does not produce any parameters.

<%=link_to "Open New Page", "https://www.foo.com/page/&quot;, {:popup => true}, {:param1 => "value1", :param2 => "value2"}%>

and

<%=link_to "Open New Page", url_for("https://www.foo.com/page/&quot;, {param1 => "value1", :param2 => "value2"}) , {:popup => true}%>

Can anyone tell me what is wrong with my code or there is a alternative way?

Thanks in advance.

Glen

Hi Shai,

Thanks you very much for the detailed explanation! Now, I understand the behavior of link_to and url_for.

Glenn

You've seen that you can't use url_for like this. In addition, you should use Hash#to_query to create the query string and then escape the HTML. This protects your link from XSS vulnerabilities and the like:

  <%= link_to "Open New Page", h('https://www.foo.com/page?’ +     {:param1 => "value1", :param2 => "value2"}.to_query), :popup => true %>