Rails 中的错误?关于模型继承
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
可以自己尝试一下;
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
In the console:
> Post.new # => TypeError: can't dup NilClass
> Post.all # => TypeError: can't dup NilClass
> Post.scoped # => TypeError: can't dup NilClass
You can try it yourself;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ActiveRecord 使用继承的方法,您需要调用 super 以便 ActiveRecord 的内容仍然运行:
ActiveRecord is using the inherited method, you need to call super so the ActiveRecord stuff still runs: