0

我做了一个 link_to_remote 但这是错误:

NoMethodError in Tasks#index

Showing /Users/overallduka/youimports_app/app/views/tasks/index.html.erb where line #6 raised:

undefined method `link_to_remote' for #<#<Class:0x1022c76f0>:0x10216ff00>
Extracted source (around line #6):

3: <div id="all_tasks">
4: <% @tasks.each do |task| %>
5: &nbsp;<%= task.title %><br />
6: <p class="about_task"><%= link_to_remote task.status,"alert('aaa')" %> <%= task.about %></p>
7: <% end %>
8: </div>

我不知道出了什么问题,我制作了一个样本警报进行测试,但错误仍然存​​在,我不知道我认为有什么问题是:

任务中的 NoMethodError#index

显示 /Users/overallduka/youimports_app/app/views/tasks/index.html.erb 其中第 6 行提出:

#<#:0x10216ff00> 的未定义方法 `link_to_remote' 提取的源代码(第 6 行附近):

<% @tasks.each do |task| %>
&nbsp;<%= task.title %><br />
<p class="about_task"><%= link_to_remote (status(task.status)),"alert('aaa')" %> <%= task.about %></p>
<% end %>
4

1 回答 1

1

link_to_remote和其他远程 ajax 助手已在 rails 3 中删除并移至 gem https://github.com/rails/prototype_legacy_helper。如果您只是在单击链接后尝试运行简单的 js,请link_to_function改用

link_to_function 'test_alert', 'alert("test")'
于 2013-02-09T15:29:26.067 回答