title: Rails 4 - How to route delete path
body: <p>I have been using Rails 3 and am trying to use Rails 4.  I am following a ToDo tutorial here: <a href="http://www.codelearn.org/ruby-on-rails-tutorial/introduction-views-layouts-helpers-assets-pipeline" rel="nofollow">http://www.codelearn.org/ruby-on-rails-tutorial/introduction-views-layouts-helpers-assets-pipeline</a></p>
  
  <p>I am trying to delete the ToDo item using the Rails 'link_to' helper method, and have been looking up online and have not been able to get it to work for the past 90 minutes so I decided to ask for help.</p>
  
  <p>Here is the error message I am getting:</p>
  
  <pre><code>Routing Error
  No route matches [DELETE] "/todos/delete_path"
  </code></pre>
  
  <p>Here is my 'rake routes' from the terminal:</p>
  
  <pre><code>Prefix Verb   URI Pattern             Controller#Action
   todos_index GET    /todos/index(.:format)  todos#index
  todos_delete DELETE /todos/delete(.:format) todos#delete
  </code></pre>
  
  <p>Here is the 'link_to' helper method from inside of the:</p>
  
  <pre><code>index.html.erb
  
  &lt;%= link_to 'Delete last todo', 'delete_path', method: :delete %&gt;
  </code></pre>
  
  <p>Here is my:</p>
  
  <pre><code>routes.rb
  
  Rails.application.routes.draw do
    get 'todos/index'
    # get 'todos/delete'
    match 'todos/delete' =&gt; 'todos#delete', via: :delete
  </code></pre>
  
  <p>Here is my:</p>
  
  <pre><code>todos_controller.rb
  
  class TodosController &lt; ApplicationController
    def index
      # @todo_array = ['Buy Milk', 'Buy Soap', 'Pay bill', 'Draw Money']
      @todo_items = Todo.all
      render :index
    end
  
    def delete
      #put delete logic here
      @todo_items = Todo.last
      @todo_items.destroy
    end
  
  end
  </code></pre>
  
  <p>Thank you for taking the time to look at my problem!</p>