diff options
author | HombreLaser <sebastian-440@live.com> | 2023-04-06 15:29:08 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2023-04-06 15:29:08 -0600 |
commit | 4611fdd6da7f9a1cc04144104e5ca26398f1b502 (patch) | |
tree | 0e04bb1a480d3484cadb9cb3e9119da27ba2c38d /app/models | |
parent | 61110336bc5a924346f0654cb5bb812101c3bc7a (diff) |
Añade specs de product_cart
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/product_cart.rb | 2 |
1 files changed, 1 insertions, 1 deletions
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 |