link_to and GET parameters

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", "", {:popup =>
true}, {:param1 => "value1", :param2 => "value2"}%>


<%=link_to "Open New Page", url_for("",
{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.


Hi Shai,

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


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

  <%= link_to “Open New Page”, h('’ +
    {:param1 => “value1”, :param2 => “value2”}.to_query), :popup => true %>