summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/carts_controller.rb2
-rw-r--r--app/models/cart.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/app/controllers/api/carts_controller.rb b/app/controllers/api/carts_controller.rb
index 0e14c17..d7c1529 100644
--- a/app/controllers/api/carts_controller.rb
+++ b/app/controllers/api/carts_controller.rb
@@ -20,7 +20,7 @@ module Api
end
def destroy
- if @cart.delete_product(product.id)
+ if @cart.delete_product(params[:id])
render status: :no_content
else
render status: :not_found
diff --git a/app/models/cart.rb b/app/models/cart.rb
index b08fc13..87e91d3 100644
--- a/app/models/cart.rb
+++ b/app/models/cart.rb
@@ -7,7 +7,7 @@ class Cart < ApplicationRecord
has_many :products, through: :product_carts
def delete_product(product_id)
- relation = product_carts.find_by(product_id:, cart_id:)
+ relation = ProductCart.find_by(product_id:, cart_id: id)
return false if relation.nil?