我不能让我的link_to助手,与:方法=>:删除销毁对象的link_to有:方法=>:删除的Rails不工作3
我的应用程序是这样的
aplication。 html.erb
<!--<!DOCTYPE html>
<html>
<head>
<title>Taskprogect</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
</head>
<body>
<%= yield %>
</body>
</html>-->
<h1>Application layout!</h1>
<%= yield %>
tasks_controller.rb
def destroy
Task.find(params[:id]).destroy
flash[:success] = "Task destroyed."
redirect_to tasks_path
end
index.html.erb
<%= link_to "delete", task, :method => :delete, :confirm => "You sure?",
:title => "Delete #{task.name}" %>
的routes.rb
Taskprogect::Application.routes.draw do
resources :projects
resources :tasks
end
而且的link_to是不行的,在以前的应用程序,工作,也许我已经做了在routes.rb中坏事?
任何想法?谢谢!
而且可以添加一些确认信息,如“你确定吗?”到button_to帮手?
为什么大部分布局注释掉了? task是在哪里定义的(因为它不是一个实例变量)?点击链接会发生什么? – polarblau 2012-01-07 20:29:09