Uninitialized constant oddities

hi there!

unfortunately, we are repeatedly having problems with uninitialized
constants in our rails app (v1.1.6), which is running on a mongrel
cluster behind apache’s mod_proxy_balancer.

---- snip ----
NameError (uninitialized constant Base):
/app/models/image.rb:90:in subclasses' /app/models/image.rb:98:in subclass?’
/app/models/image.rb:261:in count' /app/controllers/image_controller.rb:95:in list’
---- snip ----

“Base” is actually “Image::Base”, defined in lib/image/base.rb:
class Image::Base.

immediately after a mongrel_cluster restart it’s working for a few
requests, though. (approx. 4 requests, resulting from 4 mongrel
servers being run?) the strange thing just is that everything works
fine when run from script/console … except when commenting out the
“require ‘image/base’” from config/environment.rb! – how come?

code details are as follows:

app/controllers/image_controller.rb: class ImageController <

---- snip ----
def list
# Image.count is where all evil originates
@images = ::Paginator.new(Image.count, 10) { |offset, per_page|
Image.find(:all, :limit => per_page, :offset => offset)
---- snip ----

app/models/image.rb: class Image < Entity (Entity < ActiveRecord::Base):

---- snip ----
def count
return super if subclass?

subclasses.inject(0) { |sum, klass|
  sum += klass.count


def subclass?
subclasses.include? self

here’s where the uninitialized constant comes in

def subclasses(table_must_exist = true)
Image::Base.subclasses table_must_exist
---- snip ----

any ideas on what might cause this (mis-)behaviour would be greatly

TIA & cheers

Jens W., Dipl.-Bibl. (FH)
prometheus - Das verteilte digitale Bildarchiv für Forschung & Lehre
An St. Laurentius 4, 50931
KölnTel.: +49 (0)221 470-6668, E-Mail: [email protected]