Forum: Ruby on Rails Autoloading of ActiveRecord classes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
356fd043ab6081f791d09f19e91a1652?d=identicon&s=25 Eric Neumann (eneumann)
on 2007-07-31 15:12
I've extended the generation of ActiveRecords to create multiple
ActiveRecord classes for a given existing database and all of its
tables. I place the one Abstract class (that sets establish_connection
to the DB) and all of its subclassed AR files (per each table) into a
directory 'app/models/<db_name>'. I then extend the $LOAD_PATH to this
directory path, so that it can autoload the classes as needed.

The problem is, the first Abstract file does not seem to get loaded
automatically as long as its in the inner models directory, but does so
if its at the 'app/models' level. The other subclasses do seem to load
automatically within the 'app/models/<db_name>' directory.

I'm not sure if this is a load_path problem, or because I am using an
Abstract Model whose name doesn't match the inner directory name (i.e.,
'db_name_abstract'). Any suggestions on what to do or to check regarding
proper AR autoloading? I'm using Rails 1.2.2.

thanks,
Eric
This topic is locked and can not be replied to.