Loading ActiveRecord models in a Rails app from Sinatra

# This example is available on Github at https://github.com/chip/invoicethat-admin

# For simplicity's sake, I put this into app.rb

# Root directory of my Rails app
    RAILS_ROOT = '/Users/deploy/Sites/rails_invoice'

    # Setup load_paths for ActiveSupport
    require 'active_support'
    relative_load_paths = %w(app/models)
    ::ActiveSupport::Dependencies.load_paths = relative_load_paths.map { |path|
      File.expand_path(path, RAILS_ROOT)
    }
    
    # Connect to the Rails app database
    require 'active_record'
    config_path     = File.expand_path('config/database.yml', RAILS_ROOT)
    all_envs_config = YAML.load(File.read(config_path))
    config          = all_envs_config[ENV['RACK_ENV']]
    ::ActiveRecord::Base.establish_connection(config)