# Can not find superclass

**URL:** <https://rubytalk.org/t/can-not-find-superclass/31139>\
**Category:** ruby-talk\
**Created:** [20 September 2006 00:53 UTC](https://rubytalk.org/t/can-not-find-superclass/31139 "2006-09-20T00:53:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yu\_Co](https://avatars.discourse-cdn.com/v4/letter/y/f0a364/32.png) [@Yu\_Co](https://rubytalk.org/u/Yu_Co)\
**Post date:** [20 September 2006 00:53 UTC](https://rubytalk.org/t/can-not-find-superclass/31139/1 "2006-09-20T00:53:54Z")

</div>

Hi all,

I've the following:  
I defined two classes 'Super' und 'Sub' in two separate files that look  
like this:

class Super \< ActiveRecord::Base  
end

class Sub \< Super  
end

After compiling 'Sub' I get the following error message "uninitialized  
constant Super (NameError)"  
Ruby doesn't consider 'Super' as a class but rather as a constant. Does  
anyone know how I can avoid this?

Thanks in advance.

Regards,  
yussibaer

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Daniel\_N1](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@Daniel\_N1](https://rubytalk.org/u/Daniel_N1)\
**Post date:** [20 September 2006 01:06 UTC](https://rubytalk.org/t/can-not-find-superclass/31139/2 "2006-09-20T01:06:39Z")

</div>

I think it's telling you you can't call your class Super. Just choose a  
different name for it.

> **···**
>
> On 9/20/06, Yu Co \<djhackebeil@yahoo.de\> wrote:
> 
> > Hi all,
> > 
> > I've the following:  
> > I defined two classes 'Super' und 'Sub' in two separate files that look  
> > like this:
> > 
> > class Super \< ActiveRecord::Base  
> > end
> > 
> > class Sub \< Super  
> > end
> > 
> > After compiling 'Sub' I get the following error message "uninitialized  
> > constant Super (NameError)"  
> > Ruby doesn't consider 'Super' as a class but rather as a constant. Does  
> > anyone know how I can avoid this?
> > 
> > Thanks in advance.
> > 
> > Regards,  
> > yussibaer

---

<div class="post-metadata">

**Author:** ![Paul\_Lutus](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@Paul\_Lutus](https://rubytalk.org/u/Paul_Lutus)\
**Post date:** [20 September 2006 01:10 UTC](https://rubytalk.org/t/can-not-find-superclass/31139/3 "2006-09-20T01:10:05Z")

</div>

Yu Co wrote:

> Hi all,
> 
> I've the following:  
> I defined two classes 'Super' und 'Sub' in two separate files that look  
> like this:
> 
> class Super \< ActiveRecord::Base  
> end
> 
> class Sub \< Super  
> end
> 
> After compiling 'Sub' I get the following error message "uninitialized  
> constant Super (NameError)"  
> Ruby doesn't consider 'Super' as a class but rather as a constant. Does  
> anyone know how I can avoid this?
> 
> Thanks in advance.

You haven't shown enough code. Does the Sub class file have this at the top:

require 'super'

> **···**
>
> --  
> Paul Lutus  
> [http://www.arachnoid.com](http://www.arachnoid.com)

---

<div class="post-metadata">

**Author:** ![Yu\_Co](https://avatars.discourse-cdn.com/v4/letter/y/f0a364/32.png) [@Yu\_Co](https://rubytalk.org/u/Yu_Co)\
**Post date:** [20 September 2006 01:16 UTC](https://rubytalk.org/t/can-not-find-superclass/31139/4 "2006-09-20T01:16:03Z")

</div>

Daniel ----- wrote:

> **···**
>
> > On 9/20/06, Yu Co \<djhackebeil@yahoo.de\> wrote:
> > 
> > > class Sub \< Super  
> > > yussibaer
> > 
> > I think it's telling you you can't call your class Super. Just choose a  
> > different name for it.
> 
> I renamed it but unfortunately it had no effect
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Yu\_Co](https://avatars.discourse-cdn.com/v4/letter/y/f0a364/32.png) [@Yu\_Co](https://rubytalk.org/u/Yu_Co)\
**Post date:** [20 September 2006 01:21 UTC](https://rubytalk.org/t/can-not-find-superclass/31139/5 "2006-09-20T01:21:00Z")

</div>

Paul Lutus wrote:

> Yu Co wrote:
> 
> > end
> > 
> > After compiling 'Sub' I get the following error message "uninitialized  
> > constant Super (NameError)"  
> > Ruby doesn't consider 'Super' as a class but rather as a constant. Does  
> > anyone know how I can avoid this?
> > 
> > Thanks in advance.
> 
> You haven't shown enough code. Does the Sub class file have this at the  
> top:
> 
> require 'super'

That's all of the code I have. I have just two empty classes - one  
should be the subclass and the other the superclass.

After writing "require 'super'" at the top of the 'sub'file I get  
"uninitialized constant ActiveRecord (NameError)"

Odd, isn't ?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Paul\_Lutus](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@Paul\_Lutus](https://rubytalk.org/u/Paul_Lutus)\
**Post date:** [20 September 2006 01:35 UTC](https://rubytalk.org/t/can-not-find-superclass/31139/6 "2006-09-20T01:35:11Z")

</div>

Yu Co wrote:

/ ...

> > You haven't shown enough code. Does the Sub class file have this at the  
> > top:
> > 
> > require 'super'
> 
> That's all of the code I have. I have just two empty classes - one  
> should be the subclass and the other the superclass.
> 
> After writing "require 'super'" at the top of the 'sub'file I get  
> "uninitialized constant ActiveRecord (NameError)"
> 
> Odd, isn't ?

Not, it's not odd, it means that, because you put "require 'super'" at the  
top of the sub class file, the sub class found the super class, and you now  
have an new problem. The new problem is the absence of:

require 'activerecord'

at the top of the super class file.

Before, the sub class couldn't find a definition for 'super'. Now super  
can't find a definition for 'activerecord'.

Each Ruby source file that requires information from outside itself ... must  
say so.

> **···**
>
> --  
> Paul Lutus  
> [http://www.arachnoid.com](http://www.arachnoid.com)

---

<div class="post-metadata">

**Author:** ![Yu\_Co](https://avatars.discourse-cdn.com/v4/letter/y/f0a364/32.png) [@Yu\_Co](https://rubytalk.org/u/Yu_Co)\
**Post date:** [20 September 2006 02:27 UTC](https://rubytalk.org/t/can-not-find-superclass/31139/7 "2006-09-20T02:27:47Z")

</div>

Paul Lutus wrote:

> Yu Co wrote:
> 
> / ...
> 
> > Odd, isn't ?
> 
> Not, it's not odd, it means that, because you put "require 'super'" at  
> the  
> top of the sub class file, the sub class found the super class, and you  
> now  
> have an new problem. The new problem is the absence of:
> 
> require 'activerecord'
> 
> at the top of the super class file.
> 
> Before, the sub class couldn't find a definition for 'super'. Now super  
> can't find a definition for 'activerecord'.
> 
> Each Ruby source file that requires information from outside itself ...  
> must  
> say so.

Many thanks for the response Paul,  
after putting "require 'activerecord'" at the top of the super class I  
have now a new error message  
"{RUBY\_HOME}/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem\_original\_require': no such file to load -- activeRecord  
(LoadError)"  
Do you know how to handle that?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Logan\_Capaldo](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@Logan\_Capaldo](https://rubytalk.org/u/Logan_Capaldo)\
**Post date:** [20 September 2006 02:37 UTC](https://rubytalk.org/t/can-not-find-superclass/31139/8 "2006-09-20T02:37:38Z")

</div>

> Paul Lutus wrote:  
> \> Yu Co wrote:  
> \>  
> \> / ...  
> \>  
> \>\>  
> \>\> Odd, isn't ?  
> \>  
> \> Not, it's not odd, it means that, because you put "require 'super'" at  
> \> the  
> \> top of the sub class file, the sub class found the super class, and you  
> \> now  
> \> have an new problem. The new problem is the absence of:  
> \>  
> \> require 'activerecord'  
> \>  
> \> at the top of the super class file.  
> \>  
> \> Before, the sub class couldn't find a definition for 'super'. Now super  
> \> can't find a definition for 'activerecord'.  
> \>  
> \> Each Ruby source file that requires information from outside itself ...  
> \> must  
> \> say so.
> 
> Many thanks for the response Paul,  
> after putting "require 'activerecord'" at the top of the super class I  
> have now a new error message  
> "{RUBY\_HOME}/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
> `gem\_original\_require': no such file to load -- activeRecord  
> (LoadError)"  
> Do you know how to handle that?

It's require 'active\_record' (Note the underscore).

> **···**
>
> On Wed, Sep 20, 2006 at 11:27:47AM +0900, Yu Co wrote:
> 
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Yu\_Co](https://avatars.discourse-cdn.com/v4/letter/y/f0a364/32.png) [@Yu\_Co](https://rubytalk.org/u/Yu_Co)\
**Post date:** [20 September 2006 02:43 UTC](https://rubytalk.org/t/can-not-find-superclass/31139/9 "2006-09-20T02:43:40Z")

</div>

Logan Capaldo wrote:

> **···**
>
> > On Wed, Sep 20, 2006 at 11:27:47AM +0900, Yu Co wrote:
> > 
> > > \> top of the sub class file, the sub class found the super class, and you  
> > > \> Each Ruby source file that requires information from outside itself ...
> > 
> > It's require 'active\_record' (Note the underscore).
> 
> thnx logan. That's the point. And sorry for the stupid mistake of mine.
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
