Can not find superclass

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

On 9/20/06, Yu Co [email protected] 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.

Daniel ----- wrote:

On 9/20/06, Yu Co [email protected] 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

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’

Paul L. 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 ?

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.

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).

Logan C. 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.

Paul L. 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?