简体   繁体   中英

Rails link_to do block with remote=>true?

I'm trying to convert my link_to tag to a link_to do block, as discussed here . I'm not sure where the :remote=>true option should go.

Original:

<%= link_to "Title", {:controller => "users", :action => "edit", :id => u.id }, :remote => true %>

So far this is working for the link_to do block, but I don't know where to put :remote=>true. It doesn't work either in the options block or html_options.

<%= link_to (options = {:controller => "users", :action => "edit", :id => u.id}) do %>
     Link contents
<% end %>

Didn't tested, but I think the right way is

<%= link_to (url_for({:controller => "users", :action => "edit", :id => u.id}), :remote => true) do %>
     Link contents
<% end %>

Got it! Correct syntax is

<%= link_to (url_for({:controller => "users", :action => "edit", :id => u.id})), :remote => true do %>
     Link contents
<% end %>

Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM