在我单一表格继承模型中,我压倒了基准模型中 < code> 内在继承 方法,使所有后代模式都得到基准模型名称的承认。以下代码用于为所有继承的类别添加模式_name方法的替代。
def self.inherited(child)
child.instance_eval do
def model_name
BaesModelDefinition.model_name
end
end
end
我注意到,这在铁路3.2.3中产生了折旧警告:
DEPRECATION WARNING: It looks like something (probably a gem/plugin) is overriding
the ActiveRecord::Base.inherited method. It is important that this hook executes so
that your models are set up correctly. A workaround has been added to stop this
causing an error in 3.2, but future versions will simply not work if the hook is
overridden.
我还能用另一种方法来修正模型名称问题吗?