现在我的类看起来像这样。继承rails中的active_record
class BalanceName < ActiveRecord
def before_validation
set_blank_attributes_to_nil(@attributes)
end
end
class Balance < ActiveRecord
def before_validation
set_blank_attributes_to_nil(@attributes)
end
end
我想将activer记录继承到一个类中,而不是想将该类继承到其他类中。
我想要这样的东西。
class CommonActiveRecord < ActiveRecord::Base
def before_validation
set_blank_attributes_to_nil(@attributes)
end
end
class BalanceName < CommonActiveRecord
def before_validation
super
end
end
class Balance < CommonActiveRecord
def before_validation
super
end
end
:
您还需要指示轨道您
CommonActiveRecord
类是抽象的,因此不会通过增加持续。而我的其他班级将继承那个普通班级。在我的问题的第二个块中,我写了一个代码,我想要类似的东西。 – 2010-08-27 21:07:37