# Superclass mismatch

**URL:** <https://www.ruby-forum.com/t/superclass-mismatch/67595>\
**Category:** Ruby\
**Created:** [September 5, 2006, 2:56pm UTC](https://www.ruby-forum.com/t/superclass-mismatch/67595 "2006-09-05T14:56:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gareth\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@Gareth\_A](https://www.ruby-forum.com/u/Gareth_A)\
**Post date:** [September 5, 2006, 2:56pm UTC](https://www.ruby-forum.com/t/superclass-mismatch/67595/1 "2006-09-05T14:56:34Z")

</div>

Hi,

I’m getting a “superclass mismatch for class TooManyAnswersError” with  
the  
following code. Other topics I’ve found talk about code being reloaded,  
which  
I’m sure isn’t happening here.

===========  
class QuestionnaireAnswerError \< ArgumentError  
attr\_accessor :question\_id

def initialize(\*args)  
self.question\_id = args.shift  
super(args)  
end  
end

class BadAnswerCountError \< QuestionnaireAnswerError  
end

# class TooManyAnswersError \< BadAnswerCountError end

Changing the penultimate line to “class TooManyAnswersError \<  
QuestionnaireAnswerError” works (although doesn’t do what I want)

Hope someone can help work out what I’m doing wrong,  
Gareth

---

<div class="post-metadata">

**Author:** ![Gareth\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@Gareth\_A](https://www.ruby-forum.com/u/Gareth_A)\
**Post date:** [September 5, 2006, 3:10pm UTC](https://www.ruby-forum.com/t/superclass-mismatch/67595/2 "2006-09-05T15:10:36Z")

</div>

On 05/09/06, Gareth A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m getting a “superclass mismatch for class TooManyAnswersError” with the  
> following code. Other topics I’ve found talk about code being reloaded, which  
> I’m sure isn’t happening here.

Since that code appears to be fine on its own, you might need to tell  
us a little more about the surrounding code and the environment in  
which it’s running. For example, there are some pretty intractable  
complications with Rails’s automatic loading/reloading.

Paul.

---

<div class="post-metadata">

**Author:** ![Gareth\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@Gareth\_A](https://www.ruby-forum.com/u/Gareth_A)\
**Post date:** [September 5, 2006, 5:30pm UTC](https://www.ruby-forum.com/t/superclass-mismatch/67595/3 "2006-09-05T17:30:19Z")

</div>

Gareth A. wrote:

> Hope someone can help work out what I’m doing wrong,  
> Gareth

Changing your example slightly shows what could be the problem:

class QuestionnaireAnswerError \< ArgumentError  
attr\_accessor :question\_id

def initialize(\*args)  
self.question\_id = args.shift  
super(args)  
end  
end

class BadAnswerCountError \< QuestionnaireAnswerError  
end

class TooManyAnswersError \< BadAnswerCountError  
end

class TooManyAnswersError \< QuestionnaireAnswerError  
end

It looks like you’ve tried to define the class twice with different  
super classes.

HTH
