subclasses_of different result in second call

Hi,

I m using the following code to get all submodels of an sti model:

Dir.glob(RAILS_ROOT + '/app/models/*.rb').each { |file| require file}
sub_models = Object.subclasses_of(sti_model)

That works perfect in my dev environment (Rails 2.3.3) during the
first request, after I ve started my webrick. However, when the second
request is handled subclasses_of returns an array with 0 elements.

Does anybody have a hint for me what I might do wrong?

thanks a lot in advance..
volker

Hi,

I m using the following code to get all submodels of an sti model:

Dir.glob(RAILS_ROOT + '/app/models/*.rb').each { |file| require file}
sub_models = Object.subclasses_of(sti_model)

That works perfect in my dev environment (Rails 2.3.3) during the
first request, after I ve started my webrick. However, when the second
request is handled subclasses_of returns an array with 0 elements.

Does anybody have a hint for me what I might do wrong?

Because using require (rather than require_dependency) confuses rails'
code reloading system (in particular, require thinks the file is
already loaded so does not loaded it again, since it doesn't know that
rails has unloaded the previously loaded classes). Also be careful of
which path (absolute versus just the filename) you use to require the
file.

Fred