title: Loading ActiveRecord models in the proper order outside of a rails app
body: <p>How do I load/require my activerecord models in the proper order outside of a rails app.  I have many STI models and I am getting an uninitialized constant exception.</p>
  
  <pre><code>$:.push File.expand_path("../../../app/models", __FILE__)
  require "active_record"
  
  Dir["#{File.expand_path('../../../app/models', __FILE__)}/*.rb"].each do |path|
    require "#{File.basename(path, '.rb')}"
  end
  </code></pre>
  
  <p>I have a lot of jobs that I need to run with resque and I would rather not have my rails app load everytime and be deployed to all of the worker machines</p>
  
  <p>EDIT:  One point to clarify as well.  There are two projects a Rails project and a project that is a rails engine which contains my models.  I dont load the rails engine itself with my resque jobs I just use the snippet above in a separate class to load active record on the models.  This always worked until I added some STI models which because of the naming caused the children to attempt to be loaded before the parent. The rails engine project loads just fine in the rails project no issues there this is just because I am trying to use active record outside of a rails project.  </p>