From 9607fcb5a9cdc7595633336881cc0dd8aa9fb8ca Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Fri, 14 Apr 2023 20:52:50 -0600 Subject: Corrige errores de OrdersController --- app/models/payment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/payment.rb') diff --git a/app/models/payment.rb b/app/models/payment.rb index 4839de8..8be9c7f 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -8,7 +8,7 @@ class Payment < ApplicationRecord validate :card_belongs_to_user def card_belongs_to_user - return unless order.user_account.cards.find_by(id: card.id).nil? + return if Order.find_by(id: order_id)&.user_account&.cards&.exists?(card_id) errors.add(:card_id, "doesn't belong to user") end -- cgit v1.2.3