Rails 2.0/Autotest "Color is not a class"

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

On 2/24/08, Jeff C.man [email protected] 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/

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

On Feb 24, 2:55 pm, “Rick DeNatale” [email protected] 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.

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

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

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!