Rails link_to阻止与远程=> true?

时间:2013-04-25 02:33:55

标签: ruby-on-rails ruby-on-rails-3

我正在尝试将link_to代码转换为link_to do代码块,正如here所述。我不确定:remote => true选项应该去哪里。

原件:

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

到目前为止,这适用于link_to do块,但我不知道放在哪里:remote =&gt; true。它在选项块或html_options中都不起作用。

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

2 个答案:

答案 0 :(得分:6)

未经测试,但我认为正确的方法是

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

答案 1 :(得分:4)

知道了!正确的语法是

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

感谢。