# Uninitialized constant Customer (NameError)

**URL:** <https://www.ruby-forum.com/t/uninitialized-constant-customer-nameerror/57527>\
**Category:** Ruby\
**Created:** [April 11, 2006, 7:14pm UTC](https://www.ruby-forum.com/t/uninitialized-constant-customer-nameerror/57527 "2006-04-11T19:14:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gopal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gopal](https://www.ruby-forum.com/u/gopal)\
**Post date:** [April 11, 2006, 7:14pm UTC](https://www.ruby-forum.com/t/uninitialized-constant-customer-nameerror/57527/1 "2006-04-11T19:14:09Z")

</div>

Hi everybody,  
I created a class called Customer and created a sub class called  
Transaction. The problem iam facing is i can’t extract the super class  
methods and variables from sub class (i.e from Transaction class).  
the error it shows is

ruby Transaction.rb  
Transaction.rb:1: uninitialized constant Customer (NameError)

> Exit code: 1

please let me know how do i proceed…

Thanks in advance…

---

<div class="post-metadata">

**Author:** ![gopal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gopal](https://www.ruby-forum.com/u/gopal)\
**Post date:** [April 11, 2006, 8:05pm UTC](https://www.ruby-forum.com/t/uninitialized-constant-customer-nameerror/57527/2 "2006-04-11T20:05:29Z")

</div>

On 4/11/06, gopal pusuluri [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> please let me know how do i proceed…

1. Some actual code might help.
2. Huh?

-austin

---

<div class="post-metadata">

**Author:** ![gopal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gopal](https://www.ruby-forum.com/u/gopal)\
**Post date:** [April 11, 2006, 8:46pm UTC](https://www.ruby-forum.com/t/uninitialized-constant-customer-nameerror/57527/3 "2006-04-11T20:46:45Z")

</div>

gopal pusuluri schrieb:

> Hi everybody,  
> I created a class called Customer and created a sub class called  
> Transaction. The problem iam facing is i can’t extract the super class  
> methods and variables from sub class (i.e from Transaction class).  
> the error it shows is
> 
> ruby Transaction.rb  
> Transaction.rb:1: uninitialized constant Customer (NameError)
> 
> > Exit code: 1

Since you get the error in line 1 of the Transaction.rb file, I guess it  
starts with

class Transaction \< Customer

and I guess you define the class Customer in a file Customer.rb. If I’m  
correct, you first have to require the file with the Customer class, so  
your file Transaction.rb has to start with

require “Customer”  
class Transaction \< Customer

Some further remarks:

- You don’t need to name the file after the class. And you don’t have to  
define each class in its own file. For example, you could define both of  
your classes in a file called “app.rb”.

- I think Filenames with mixed uppercase and lowercase letters aren’t  
often used in Ruby land.

- How can a transaction be a subclass of a customer?

Regards,  
Pit

---

<div class="post-metadata">

**Author:** ![gopal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gopal](https://www.ruby-forum.com/u/gopal)\
**Post date:** [April 12, 2006, 1:11pm UTC](https://www.ruby-forum.com/t/uninitialized-constant-customer-nameerror/57527/4 "2006-04-12T13:11:55Z")

</div>

Hi Mr.Pit  
Thanks for the solid information that u posted, yes the require  
“Customer” is the sentence which i missed out…

Thanks again for ur info,  
bye

Pit C. wrote:

> gopal pusuluri schrieb:
> 
> > Hi everybody,  
> > I created a class called Customer and created a sub class called  
> > Transaction. The problem iam facing is i can’t extract the super class  
> > methods and variables from sub class (i.e from Transaction class).  
> > the error it shows is
> > 
> > ruby Transaction.rb  
> > Transaction.rb:1: uninitialized constant Customer (NameError)
> > 
> > > Exit code: 1
> 
> Since you get the error in line 1 of the Transaction.rb file, I guess it  
> starts with
> 
> class Transaction \< Customer
> 
> and I guess you define the class Customer in a file Customer.rb. If I’m  
> correct, you first have to require the file with the Customer class, so  
> your file Transaction.rb has to start with
> 
> require “Customer”  
> class Transaction \< Customer
> 
> Some further remarks:
> 
> - You don’t need to name the file after the class. And you don’t have to  
> define each class in its own file. For example, you could define both of  
> your classes in a file called “app.rb”.
> 
> - I think Filenames with mixed uppercase and lowercase letters aren’t  
> often used in Ruby land.
> 
> - How can a transaction be a subclass of a customer?
> 
> Regards,  
> Pit
