blob: 4839de89c11b28467f7c7f9a306fc281dd7c14df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# frozen_string_literal: true
# Payment
# total: float
class Payment < ApplicationRecord
has_one :order
belongs_to :card
validate :card_belongs_to_user
def card_belongs_to_user
return unless order.user_account.cards.find_by(id: card.id).nil?
errors.add(:card_id, "doesn't belong to user")
end
end
|