From 4611fdd6da7f9a1cc04144104e5ca26398f1b502 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 6 Apr 2023 15:29:08 -0600 Subject: AƱade specs de product_cart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/product_cart.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/product_cart.rb b/app/models/product_cart.rb index eb9cf9f..09e7a25 100644 --- a/app/models/product_cart.rb +++ b/app/models/product_cart.rb @@ -10,7 +10,7 @@ class ProductCart < ApplicationRecord validate :sole_product_in_cart def sole_product_in_cart - return if cart.products.find_by(id: product_id).nil? + return if cart.nil? || cart.products.find_by(id: product_id).nil? errors.add(:product_id, "cart already has product with id #{product_id}") end -- cgit v1.2.3