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 < ApplicationController:
---- 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) }.page(params[:page]) end ---- 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 } end
def subclass? subclasses.include? self end
# here's where the uninitialized constant comes in def subclasses(table_must_exist = true) Image::Base.subclasses table_must_exist end ---- snip ----
any ideas on what might cause this (mis-)behaviour would be greatly appreciated.
TIA & cheers jens