# Uninitialized constant error

**URL:** <https://www.ruby-forum.com/t/uninitialized-constant-error/155919>\
**Category:** Rails\
**Created:** [December 18, 2008, 6:53am UTC](https://www.ruby-forum.com/t/uninitialized-constant-error/155919 "2008-12-18T06:53:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wudntme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/54ee81/32.png) [@wudntme](https://www.ruby-forum.com/u/wudntme)\
**Post date:** [December 18, 2008, 6:53am UTC](https://www.ruby-forum.com/t/uninitialized-constant-error/155919/1 "2008-12-18T06:53:03Z")

</div>

Hi, all. Hoping someone can help me with an error I can’t figure out.

## FILE: quote.rb

## module BUYER class Quote … end end

## FILE: quotes\_controller.rb

## require ‘quote’ … class QuotesController … def this\_method q = BUYER::Quote.new(params[:id]) end end

## When I run this\_method, I get the error:

## uninitialized constant BUYER::Quote

I am able to access other classes from BUYER in exactly the same way,  
and do not receive an error. I’m still trying to get used to Ruby’s  
conventions, and I wonder if anyone can see anything I did wrong.

## I should mention that the two files listed are in different directories. quote.rb is in a library which I have referenced in environment.rb with the line

## config.load\_paths += %W( #{RAILS\_ROOT}/…/software/src/QuoteGenerator/lib )

The classes I mentioned in the previous paragraph, which I am able to  
refer to without error, are also located in this lib directory, so I  
know it’s not just an issue of not being able to see my includes or  
something.

Is the fact that I have two different objects with the same name perhaps  
causing problems? I would think this would be resolved by use of the  
namespace – err, excuse me, module – syntax.

I’ve seen a bunch of replies to queries of this sort suggesting that  
improper pluralization is the problem, so I am hoping that my problem  
here is a similarly simple fix.

Please let me know if I am lacking any important info.

Thanks,  
Jerry

---

<div class="post-metadata">

**Author:** ![wudntme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/54ee81/32.png) [@wudntme](https://www.ruby-forum.com/u/wudntme)\
**Post date:** [December 19, 2008, 9:27am UTC](https://www.ruby-forum.com/t/uninitialized-constant-error/155919/2 "2008-12-19T09:27:49Z")

</div>

> Is the fact that I have two different objects with the same name perhaps  
> causing problems? I would think this would be resolved by use of the  
> namespace – err, excuse me, module – syntax.

This was indeed the problem. I changed the name of the object Quote to  
Qquote, updated all references to it, and left the name of the Quote  
model as it is. It works now.
