# Rails 2.0/Autotest "Color is not a class"

**URL:** <https://www.ruby-forum.com/t/rails-2-0-autotest-color-is-not-a-class/130043>\
**Category:** Rails\
**Created:** [February 24, 2008, 9:19pm UTC](https://www.ruby-forum.com/t/rails-2-0-autotest-color-is-not-a-class/130043 "2008-02-24T21:19:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [February 24, 2008, 9:19pm UTC](https://www.ruby-forum.com/t/rails-2-0-autotest-color-is-not-a-class/130043/1 "2008-02-24T21:19:12Z")

</div>

I’ve made a model called Color to manage custom styles for my  
application. It works find when I’m running it locally in Mongrel,  
and I haven’t tried to deploy it yet.

I use ZenTest and Autotest, and when I run autotest I’m getting the  
following message:

“C:/rails/band/trunk/app/models/color.rb:1: Color is not a class  
(TypeError)”

My Color model is very simple:

class Color \< ActiveRecord::Base  
belongs\_to :setting

validates\_presence\_of :title  
end

I’ve run ‘rake db:test:clone’ to make sure the test database is  
prepared. The application works normally in development mode, but it  
blows up in autotest. I’m not sure what’s going on.

Any ideas?

Thanks,  
Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [February 24, 2008, 9:56pm UTC](https://www.ruby-forum.com/t/rails-2-0-autotest-color-is-not-a-class/130043/2 "2008-02-24T21:56:22Z")

</div>

On 2/24/08, Jeff C.man [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve made a model called Color to manage custom styles for my  
> application. It works find when I’m running it locally in Mongrel,  
> and I haven’t tried to deploy it yet.
> 
> I use ZenTest and Autotest, and when I run autotest I’m getting the  
> following message:
> 
> “C:/rails/band/trunk/app/models/color.rb:1: Color is not a class  
> (TypeError)”

This message is complaining that there’s already a constant called  
Color and it’s not a class.

Running this simple Ruby program give the same error:

Color = “Red”

class Color  
end

Now where the Color constant is being defined, I’m not sure, but I’m  
pretty sure that it’s not in Rails itself, my guess would be either  
somewhere in your own code, or in a gem or plugin you are using.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [February 24, 2008, 10:03pm UTC](https://www.ruby-forum.com/t/rails-2-0-autotest-color-is-not-a-class/130043/3 "2008-02-24T22:03:29Z")

</div>

chances it’s a naming collision  
rename your class and you will see

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [February 24, 2008, 10:07pm UTC](https://www.ruby-forum.com/t/rails-2-0-autotest-color-is-not-a-class/130043/4 "2008-02-24T22:07:02Z")

</div>

On Feb 24, 2:55 pm, “Rick DeNatale” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This message is complaining that there’s already a constant called  
> Color and it’s not a class.

Thanks! Any ideas on why it would create a conflict in Test mode but  
not in Development? I’ll look through the plugins I’ve got and see if  
it’s defined anywhere else.

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [February 24, 2008, 11:17pm UTC](https://www.ruby-forum.com/t/rails-2-0-autotest-color-is-not-a-class/130043/5 "2008-02-24T23:17:47Z")

</div>

I believe it’s not environment related  
I bet you are using redgreen, and it has module, named Color in  
redgreen.rb

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [February 25, 2008, 9:28am UTC](https://www.ruby-forum.com/t/rails-2-0-autotest-color-is-not-a-class/130043/6 "2008-02-25T09:28:01Z")

</div>

I edited redgreen so the Color class is in its own module, thus  
eliminating the conflict. Works perfectly now!

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [February 25, 2008, 12:01am UTC](https://www.ruby-forum.com/t/rails-2-0-autotest-color-is-not-a-class/130043/7 "2008-02-25T00:01:25Z")

</div>

That would be it. It IS environment-related, in the sense that  
redgreen doesn’t load except in testing, so that would explain it.

Woot!
