My env: ruby-1.9.2-preview3; rails-3.0.0.beta3
class PostFather < ActiveRecord::Base
def self.inherited(subclass)
end
end
class Post < PostFather
end
在控制台中:
> Post.new # => TypeError: can't dup NilClass
> Post.all # => TypeError: can't dup NilClass
> Post.scoped # => TypeError: can't dup NilClass
你可以亲自尝试一下;
答案 0 :(得分:1)
ActiveRecord正在使用继承方法,你需要调用super,以便ActiveRecord的东西仍在运行:
class PostFather < ActiveRecord::Base
def self.inherited(subclass)
super(subclass)
end
end