title: Rails delete link nested routes
body: <p>I'm writing a simple todo app which has projects and projects has many tasks.  I want to be able to delete a task within a project.  But when I try to link_to a delete method I get undefined method 'task_path'.</p>
  
  <p>view code</p>
  
  <pre><code>&lt;ul&gt;
    &lt;% @project.tasks.each do |task| %&gt;
      &lt;li&gt;&lt;%= task.name %&gt;&lt;/li&gt; &lt;%= link_to "delete", task, :method  =&gt; :delete %&gt;&lt;/br&gt;
    &lt;% end %&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>tasks controller</p>
  
  <pre><code>  def destroy
      @project = Project.find(params[:project_id])
      @task = @project.tasks.find(params[:id])
      @task.destroy
      redirect_to @project, :notice =&gt; "Task Deleted"
    end
  </code></pre>
  
  <p>routes.rb</p>
  
  <pre><code> resources :projects do
      resources :tasks
    end
  </code></pre>
  
  <p>Update:
  So I have delete working.  But now as I'm iterating through each task, there's an extra delete link which routes to <a href="http://todoapp.dev/projects/9/tasks" rel="nofollow noreferrer">http://todoapp.dev/projects/9/tasks</a> and gives No route matches [DELETE] "/projects/9/tasks"  Why is the extra delete link in there?</p>
  
  <pre><code> &lt;% @project.tasks.each do |task| %&gt;
      &lt;%= task.name %&gt; &lt;%= link_to "delete", [@project, task], :method  =&gt; :delete %&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/acSFZ.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/YBH7Z.png" alt="enter image description here"></p>