【发布时间】:2013-04-18 22:11:41
【问题描述】:
如果我有这样的模型:
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 不需要验证交易是否结算?
【问题讨论】:
-
您使用的是 Rails 3 还是 Rails 4?这个问题被标记为两者。
标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-4