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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> 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 %> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.