# Autoloading of ActiveRecord classes

**URL:** <https://www.ruby-forum.com/t/autoloading-of-activerecord-classes/110846>\
**Category:** Rails\
**Created:** [July 31, 2007, 3:12pm UTC](https://www.ruby-forum.com/t/autoloading-of-activerecord-classes/110846 "2007-07-31T15:12:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nielsene](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/bc79bd/32.png) [@nielsene](https://www.ruby-forum.com/u/nielsene)\
**Post date:** [July 31, 2007, 3:12pm UTC](https://www.ruby-forum.com/t/autoloading-of-activerecord-classes/110846/1 "2007-07-31T15:12:18Z")

</div>

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
