Reputation: 977
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?
Upvotes: 0
Views: 2626
Reputation: 3818
can you view html source in your web browser when the page actually get rendered? you should see references to your jQuery source files, if you are using jQuery.
for example:
<script src="/public/javascripts/jquery.js?body=1" type="text/javascript"></script>
<script src="/public/javascripts/jquery_ujs.js?body=1" type="text/javascript"></script>
Then, check if there exists these physical jquery source files or not? Those could have been missing. If this will be the case, just copy over those missing files to their intended locations.
hope this help.
Upvotes: 1
Reputation: 27961
The whole head of your layout template is commented out, which means that the javascript include is commented out, which means that JS that adds the magic to :method => :delete
links is not being run.
Upvotes: 3