Если у меня есть модели, как это:Single Table Inheritance с проверкой рубин на рельсах
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? Таким образом, транзакция родительского класса и CashTransaction не нуждается в проверке того, была ли транзакция решена?
Вы находитесь на Rails 3 или Rails 4? Этот вопрос отмечен как оба. – Substantial