title: ActiveRecord::InvalidForeignKey Error
body: <p>When I try to delete something from my inventory database, I get this error:</p>
  
  <pre><code>ActiveRecord::InvalidForeignKey in InventoriesController#destroy
  
  SQLite3::ConstraintException: FOREIGN KEY constraint failed: DELETE FROM "inventories" WHERE "inventories"."id" = ?
  </code></pre>
  
  <p>In the terminal, it says</p>
  
  <pre><code>{"_method"=&gt;"delete", "authenticity_token"=&gt;"dBNU2GkV0+rOcp4NVEljm4oIpkdOnPsvZKdmisaadBzX3QkY1VwurZNRPL0WFtVvizeAcJb7H6E50ObmpRsXAg==", "id"=&gt;"1"}
  </code></pre>
  
  <p>It also says the source is at:</p>
  
  <pre><code> def destroy
      @inventory = Inventory.find(params[:id])
      @inventory.destroy
  
      redirect_to inventory_path
  end
  </code></pre>
  
  <p>In my inventories file which is:</p>
  
  <pre><code>class InventoriesController &lt; ApplicationController
      def show
          @inventory = Inventory.find(params[:id])
       end
  
      def index
          @inventories = Inventory.all
      end
  
      def new
          @inventory = Inventory.new
      end
  
      def create
          @inventory = Inventory.new(inventory_params)
  
  
          if @inventory.save
          redirect_to @inventory
          else
              render 'new'
          end
      end
  
      def edit
          @inventory = Inventory.find(params[:id])
      end
  
      def update
          @inventory = Inventory.find(params[:id])
          if @inventory.update(inventory_params)
              redirect_to @inventory
          else
              render 'edit'
          end
      end
  
      def destroy
          @inventory = Inventory.find(params[:id])
          @inventory.destroy
  
          redirect_to inventory_path
      end
  end
  
  private 
  def inventory_params
      params.require(:inventory).permit(:product_name, :brand_name, :item_id, :upc_code, :color, :department, :size, :condition, :fabric_type, :shipping_weight, :sku, :asin, :quantity, :cost_price, :sell_price, :key_product_features, :product_description, :search_terms, :status, :listing_in_usa, :listing_in_canada, :listing_in_mexico)
  
  end
  </code></pre>