title: No route matches [DELETE] for nested resources
body: <p>I have a nested model setup, where users have multiple manufacturers, and manufacturers have multiple lines. When I try to delete the instance of the line from the line index, I get a bad route message. I'm not sure what I'm doing wrong, but it's probably something simple, was hoping someone could save me some heartache here. I've read the hartl stuff and I'm still very very new to nested resources and routes.</p>
  
  <p>===MODELS===</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :trackable, :validatable
    has_many :manufacturers
  end
  </code></pre>
  
  <p>======</p>
  
  <pre><code>class Manufacturer &lt; ActiveRecord::Base
    belongs_to :user
    has_many :lines
  end
  </code></pre>
  
  <p>======</p>
  
  <pre><code>class Line &lt; ActiveRecord::Base
    belongs_to :manufacturer
  end
  </code></pre>
  
  <p>======</p>
  
  <p>lines_controller.rb</p>
  
  <pre><code>class LinesController &lt; ApplicationController
    before_action :set_line, only: [:show, :edit, :update, :destroy]
    before_filter :load_manufacturer
  
    # GET /lines
    # GET /lines.json
    def index
      @lines = Line.all
    end
  
    # GET /lines/1
    # GET /lines/1.json
    def show
    end
  
    # GET /lines/new
    def new
      @manufacturer = Manufacturer.find(params[:manufacturer_id])
      @line = @manufacturer.lines.build
    end
  
    # GET /lines/1/edit
    def edit
    end
  
    # POST /lines
    # POST /lines.json
    def create
      @line = @manufacturer.lines.build(line_params)
  
      respond_to do |format|
        if @line.save
          format.html { redirect_to manufacturer_line_path(@manufacturer, @line), notice: 'Line was successfully created.' }
          format.json { render action: 'show', status: :created, location: @line }
        else
          format.html { render action: 'new' }
          format.json { render json: @line.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # PATCH/PUT /lines/1
    # PATCH/PUT /lines/1.json
    def update
      respond_to do |format|
        if @line.update(line_params)
          format.html { redirect_to manufacturer_line_path(@manufacturer, @line), notice: 'Line was successfully updated.' }
          format.json { head :no_content }
        else
          format.html { render action: 'edit' }
          format.json { render json: @line.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # DELETE /lines/1
    # DELETE /lines/1.json
    def destroy
      @manufacturer.line.destroy
      respond_to do |format|
        format.html { redirect_to lines_url }
        format.json { head :no_content }
      end
    end
  
    private
      # Use callbacks to share common setup or constraints between actions.
      def set_line
        @line = Line.find(params[:id])
      end
  
      # Never trust parameters from the scary internet, only allow the white list through.
      def line_params
        params.require(:line).permit(:name, :manufacturer_id)
      end
  
      def load_manufacturer
        @manufacturer = Manufacturer.find(params[:manufacturer_id])
      end
  end
  </code></pre>
  
  <p>=====</p>
  
  <pre><code>                  Prefix Verb   URI Pattern                                              Controller#Action
        manufacturer_lines GET    /manufacturers/:manufacturer_id/lines(.:format)          lines#index
                           POST   /manufacturers/:manufacturer_id/lines(.:format)          lines#create
     new_manufacturer_line GET    /manufacturers/:manufacturer_id/lines/new(.:format)      lines#new
    edit_manufacturer_line GET    /manufacturers/:manufacturer_id/lines/:id/edit(.:format) lines#edit
         manufacturer_line GET    /manufacturers/:manufacturer_id/lines/:id(.:format)      lines#show
                           PATCH  /manufacturers/:manufacturer_id/lines/:id(.:format)      lines#update
                           PUT    /manufacturers/:manufacturer_id/lines/:id(.:format)      lines#update
                           DELETE /manufacturers/:manufacturer_id/lines/:id(.:format)      lines#destroy
             manufacturers GET    /manufacturers(.:format)                                 manufacturers#index
                           POST   /manufacturers(.:format)                                 manufacturers#create
          new_manufacturer GET    /manufacturers/new(.:format)                             manufacturers#new
         edit_manufacturer GET    /manufacturers/:id/edit(.:format)                        manufacturers#edit
              manufacturer GET    /manufacturers/:id(.:format)                             manufacturers#show
                           PATCH  /manufacturers/:id(.:format)                             manufacturers#update
                           PUT    /manufacturers/:id(.:format)                             manufacturers#update
                           DELETE /manufacturers/:id(.:format)                             manufacturers#destroy
          new_user_session GET    /users/sign_in(.:format)                                 devise/sessions#new
              user_session POST   /users/sign_in(.:format)                                 devise/sessions#create
      destroy_user_session DELETE /users/sign_out(.:format)                                devise/sessions#destroy
             user_password POST   /users/password(.:format)                                devise/passwords#create
         new_user_password GET    /users/password/new(.:format)                            devise/passwords#new
        edit_user_password GET    /users/password/edit(.:format)                           devise/passwords#edit
                           PATCH  /users/password(.:format)                                devise/passwords#update
                           PUT    /users/password(.:format)                                devise/passwords#update
  cancel_user_registration GET    /users/cancel(.:format)                                  devise/registrations#cancel
         user_registration POST   /users(.:format)                                         devise/registrations#create
     new_user_registration GET    /users/sign_up(.:format)                                 devise/registrations#new
    edit_user_registration GET    /users/edit(.:format)                                    devise/registrations#edit
                           PATCH  /users(.:format)                                         devise/registrations#update
                           PUT    /users(.:format)                                         devise/registrations#update
                           DELETE /users(.:format)                                         devise/registrations#destroy
                      root GET    /                                                        pages#home
                     about GET    /about(.:format)                                         pages#about
                           GET    /users/:id(.:format)                                     users#show
                 all_users GET    /users(.:format)                                         users#index
            public_profile GET    /users/:name(.:format)                                   users#show
  </code></pre>
  
  <p>======</p>
  
  <p>app/views/lines/index.html.erb</p>
  
  <pre><code>&lt;h1&gt;Listing lines&lt;/h1&gt;
  
  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Name&lt;/th&gt;
        &lt;th&gt;Manufacturer&lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
  
    &lt;tbody&gt;
      &lt;% @lines.each do |line| %&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;%= line.name %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= line.manufacturer_id %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'Show', manufacturer_lines_path(line.manufacturer, line) %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'Edit', edit_manufacturer_line_path(line.manufacturer, line) %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'Destroy', manufacturer_lines_path, method: :delete, data: { confirm: 'Are you sure?' } %&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;% end %&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;br&gt;
  </code></pre>