Un bug in rotaie? A proposito di modello ereditato
-
28-09-2019 - |
Domanda
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
Nella console:
> Post.new # => TypeError: can't dup NilClass
> Post.all # => TypeError: can't dup NilClass
> Post.scoped # => TypeError: can't dup NilClass
Si può provare da soli;
Soluzione
ActiveRecord sta usando il metodo ereditato, è necessario chiamare super-così la roba ActiveRecord corre ancora:
class PostFather < ActiveRecord::Base
def self.inherited(subclass)
super(subclass)
end
end
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow