如果我有这样的模型:
class Transaction < ActiveRecord
# create table called transactions and add type column to it.
# add common methods inside this class
end
class CashTransaction < Transaction
# the type column will be CashTransaction and used to determine entry for this class in transactions table
end
class CreditCardTransaction < Transaction
validates :settled, :presence => true
# the type column will be CreditCardTransaction and used to determine entry for this class in transactions table
end
如何应用 CreditCardTransaction 独有的验证?那么父类 Transaction 和 CashTransaction 不需要验证交易是否已结算?