I can't get my link_to helper, with :method => :delete to destroy object
My app is like this
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
And link_to doesn't work, in previous app that worked, maybe I have done something bad in routes.rb?
Any ideas? Thanks!
And can it be added some confirmation, like "Are you sure?" to button_to helper?
task
defined (since it's not an instance variable)? What happens when you click the link? – polarblau