How to run validations of sub-class in Single Table Inheritance?
问题 In my application, I have a class called Budget. The budget can be of many types.. For instance, let's say that there are two budgets: FlatRateBudget and HourlyRateBudget. Both inherit from the class Budget. This is what I get so far: class Budget < ActiveRecord::Base validates_presence_of :price end class FlatRateBudget < Budget end class HourlyRateBudget < Budget validates_presence_of :quantity end In the console, if I do: b = HourlyRateBudget.new(:price => 10) b.valid? => false b.errors