Ruby on rails 3:link_to:remote => true将“remote”视为URL参数

时间:2011-07-17 00:56:47

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

我想知道link_to语法应该用于制作ajax请求(或其他想法,这里可能会出现问题)。目前我有

<%= form_tag "save_sets", :remote => true, :name => "set_form" do %>

在文件中,它完美无缺。但是,在同一个文件中,所有

<%= link_to assignment.name, :action => :view_student_problem_set, :remote => true %>
<%= link_to assignment.name, :remote => true, :action => :view_student_problem_set %>
<%= link_to assignment.name, {:action => :view_student_problem_set, :remote => true} %>
<%= link_to assignment.name, {:remote => true, :action => :view_student_problem_set} %>
<%= link_to assignment.name, {:remote => true}, {:action => :view_student_problem_set} 
<%= link_to assignment.name, {:remote => true}, :action => :view_student_problem_set %>

只使用“?remote = true”而不是data-remote =“true”和

生成链接
<%= link_to assignment.name, :remote => true, {:action => :view_student_problem_set} %>

显然是语法错误。

我尝试过的大部分组合来自教程,论坛帖子和文档。我不认为符号集合必须按特定顺序排列,但我只是在彻底。无论如何,我的谷歌搜索技巧已经达到了他们的匹配。

form_tag和link_to标签之间的相关jquery代码,控制器代码等等都是相同的。

谢谢,等等。

1 个答案:

答案 0 :(得分:12)

<%= link_to assignment.name, {:action => :view_student_problem_set}, :remote => true %>