wrong link_to html output

I've just upgraded from rails 2 to 3 and got some problems with the link_to method!

A line like this:

<%= link_to "Lab", :action => :showlab, :remote => true %>

creates a html link like this:

<a href="controller/showlab?remote=true">Lab</a>

and not like this:

<a href="controller/showlab" data-remote="true">Lab</a>

Is there anything wrong with the link_to syntax/line? Everything works fine when I insert the right html code manually in the html.erb file. I've tried rails 3.0.0 and 3.0.1 with ruby 1.8.7 and 1.9.2

Any ideas? /landge

Is there anything wrong with the link_to syntax/line?

Yes. The link_to method has the following signatures:

link_to(body, url_options = {}, html_options = {}) link_to(body, url, html_options = {})

When you specify it like you have, Ruby thinks both :action and :remote are part of the url_options hash.

You need to explicitly separate the url_options hash and the html_options has for it to work:

<%= link_to "Lab", { :action => :showlab }, :remote => true %>

Tim Shaffer wrote in post #955238:

You need to explicitly separate the url_options hash and the html_options has for it to work:

<%= link_to "Lab", { :action => :showlab }, :remote => true %>

Oh, great. That's it! Everything works now. Thanks a lot.