From: Mauricio Fernandez Date: 2006-08-07T18:21:36+09:00 Subject: Re: Superclass mismatches On Mon, Aug 07, 2006 at 05:10:11PM +0900, listrecv@gmail.com wrote: > irb(main):015:0> ResellerCategory > => Taxonomy::ResellerCategory > irb(main):016:0> ResellerCategory.superclass > => Taxonomy::Category > irb(main):017:0> ResellerCategory.superclass == Taxonomy::Category > => false [...] > irb(main):018:0> ResellerCategory.superclass.object_id > => 46413760 > irb(main):019:0> Taxonomy::Category.object_id > => 47673490 [...] > irb(main):020:0> module Taxonomy; class ResellerCategory < Category; > end ; end > TypeError: superclass mismatch for class ResellerCategory > irb(main):023:0> module Taxonomy; class ResellerCategory < > ResellerCategory.superclass; end ; end > => nil > > My questions are: > 1) How did that happen? It seems like 1 != 1 Taxonomy::Category has been redefined, as if you were doing module Taxonomy; Category = Class.new { ... } end or maybe module Taxonomy; remove_const :Category; class Category; ... end end and that were being evaluated more than once. Can you show the code? > 2) More importantly, how can I stop this error from happening? (It's > caused when the file defining ResellerCategory is loaded a second time) You have to make sure that Taxonomy::Category references the same class all the time. If you can't find why it's changing, you can get by with module Taxonomy; class ResellerCategory < Category; end end which must be eval()ed only once, and then replacing in the file to be loaded repeatedly class ResellerCategory < Category with class ResellerCategory HTH -- Mauricio Fernandez - http://eigenclass.org - singular Ruby