title: Delete method doesn't work rails controller
body: <p>I've made some updates to my app, but then It can't destroy existing category.</p>
  <p>I just want to destroy existing category with confirmation.</p>
  <p>Here my code</p>
  <p>index.html.erb generating list of existing categories</p>
  <pre><code>&lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Category&lt;/th&gt;
        &lt;th colspan=&quot;3&quot;&gt;&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
  
    &lt;tbody&gt;
      &lt;% @categories.each do |category| %&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;%= category.category %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'Show', category %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'Edit', edit_category_path(category) %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'Destroy', category, method: :delete, data: { confirm: 'Are you sure?' } %&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;% end %&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  <p>categories_controller.erb actual controller i'm using</p>
  <pre><code>class CategoriesController &lt; ApplicationController
    before_action :set_category, only: [:show, :edit, :update, :destroy]
  
    # GET /categories
    # GET /categories.json
    def index
      @categories = Category.all
    end
  
    # GET /categories/1
    # GET /categories/1.json
    def show
    end
  
    # GET /categories/new
    def new
      @category = Category.new
    end
  
    # GET /categories/1/edit
    def edit
    end
  
    # POST /categories
    # POST /categories.json
    def create
      @category = Category.new(category_params)
  
      respond_to do |format|
        if @category.save
          format.html { redirect_to @category, notice: 'Category was successfully created.' }
          format.json { render :show, status: :created, location: @category }
        else
          format.html { render :new }
          format.json { render json: @category.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # PATCH/PUT /categories/1
    # PATCH/PUT /categories/1.json
    def update
      respond_to do |format|
        if @category.update(category_params)
          format.html { redirect_to @category, notice: 'Category was successfully updated.' }
          format.json { render :show, status: :ok, location: @category }
        else
          format.html { render :edit }
          format.json { render json: @category.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # DELETE /categories/1
    # DELETE /categories/1.json
    def destroy
      @category.destroy
      respond_to do |format|
        format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }
        format.json { head :no_content }
      end
    end
  
    private
      # Use callbacks to share common setup or constraints between actions.
      def set_category
        @category = Category.find(params[:id])
      end
  
      # Only allow a list of trusted parameters through.
      def category_params
        params.require(:category).permit(:category)
      end
  end
  
  </code></pre>
  <p>model category.rb and the model containing has and belongs to many</p>
  <pre><code>class Category &lt; ApplicationRecord
    has_and_belongs_to_many :blogs
  end
  </code></pre>
  <p>Any ideas?</p>
  <p>Thank you in advance</p>