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:
Lab
and not like this:
Lab
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
landge
October 18, 2010, 10:12pm
#2
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 %>
landge
October 18, 2010, 10:26pm
#3
Tim S. 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.