# Undefined class/module

**URL:** <https://www.ruby-forum.com/t/undefined-class-module/59166>\
**Category:** Rails\
**Created:** [April 29, 2006, 4:20pm UTC](https://www.ruby-forum.com/t/undefined-class-module/59166 "2006-04-29T16:20:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/f17d59/32.png) [@yash](https://www.ruby-forum.com/u/yash)\
**Post date:** [April 29, 2006, 4:20pm UTC](https://www.ruby-forum.com/t/undefined-class-module/59166/1 "2006-04-29T16:20:25Z")

</div>

Hi,

We are running a Rails application in development mode. Intermittenly we  
get an error on some pages, saying : undefine class/module User. If we  
refresh the page, the error goes away and we see the html correctly  
rendered. User is a model defined in the models directory and has been  
listed in application.rb as model :user.

I am suprised by the fact that this happens only occasionally. Can  
someone suggest what might have gone wrong?

Thanks,  
Yash

---

<div class="post-metadata">

**Author:** ![yash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/f17d59/32.png) [@yash](https://www.ruby-forum.com/u/yash)\
**Post date:** [April 29, 2006, 7:27pm UTC](https://www.ruby-forum.com/t/undefined-class-module/59166/2 "2006-04-29T19:27:55Z")

</div>

Yash wrote:

> Hi,
> 
> We are running a Rails application in development mode. Intermittenly we  
> get an error on some pages, saying : undefine class/module User. If we  
> refresh the page, the error goes away and we see the html correctly  
> rendered. User is a model defined in the models directory and has been  
> listed in application.rb as model :user.
> 
> I am suprised by the fact that this happens only occasionally. Can  
> someone suggest what might have gone wrong?
> 
> Thanks,  
> Yash

I have seen this problem too. It seems to happen when the system is  
under heavy load. I suspect that the reflection technique used to  
get the table details is hitting some timeout when trying to access  
the database.  
The environment where it occasionally occurs for me is  
– Development mode, Rails 1.0, Ruby 1.8.4  
– Linux  
– Postgres  
– Webrick using SSL  
– Heavy load

My questions:  
If a timeout occurs on db access, shouldn’t Rails just retry later?  
(that would be the robust thing)  
How can development mode cause this kind of error? (makes things slower,  
yes … but they shouldn’t _break_).

– Mike B.

---

<div class="post-metadata">

**Author:** ![yash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/f17d59/32.png) [@yash](https://www.ruby-forum.com/u/yash)\
**Post date:** [January 17, 2007, 6:04am UTC](https://www.ruby-forum.com/t/undefined-class-module/59166/3 "2007-01-17T06:04:26Z")

</div>

phoenix wrote:

> l right when this Controller be called the first time,then it  
> will nerver run,just raise this exception:undefined class/module Cring  
> After restart my Webrick,it will be right just once,then raise  
> exception!

I had similar errors until I updated to Rails 1.2RC2.

---

<div class="post-metadata">

**Author:** ![yash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/f17d59/32.png) [@yash](https://www.ruby-forum.com/u/yash)\
**Post date:** [January 17, 2007, 3:09am UTC](https://www.ruby-forum.com/t/undefined-class-module/59166/4 "2007-01-17T03:09:18Z")

</div>

Mike B. wrote:

> Yash wrote:
> 
> > Hi,
> > 
> > We are running a Rails application in development mode. Intermittenly we  
> > get an error on some pages, saying : undefine class/module User. If we  
> > refresh the page, the error goes away and we see the html correctly  
> > rendered. User is a model defined in the models directory and has been  
> > listed in application.rb as model :user.
> > 
> > I am suprised by the fact that this happens only occasionally. Can  
> > someone suggest what might have gone wrong?
> > 
> > Thanks,  
> > Yash
> 
> I have seen this problem too. It seems to happen when the system is  
> under heavy load. I suspect that the reflection technique used to  
> get the table details is hitting some timeout when trying to access  
> the database.  
> The environment where it occasionally occurs for me is  
> – Development mode, Rails 1.0, Ruby 1.8.4  
> – Linux  
> – Postgres  
> – Webrick using SSL  
> – Heavy load
> 
> My questions:  
> If a timeout occurs on db access, shouldn’t Rails just retry later?  
> (that would be the robust thing)  
> How can development mode cause this kind of error? (makes things slower,  
> yes … but they shouldn’t _break_).
> 
> – Mike B.

I am under ruby 1.8.5,rails 1.1.6,Development mode,system is not under  
heavy load:  
require ‘Cring’  
class QueryController \< ApplicationController  
…  
@@score\_cache ||= File.zero?(‘score.cache’) ? Hash.new :  
Marshal.load(@@f)  
…  
It’s all right when this Controller be called the first time,then it  
will nerver run,just raise this exception:undefined class/module Cring  
After restart my Webrick,it will be right just once,then raise  
exception!
