Using AR outside of rails

I’ve seen a number of ways to use AR outside of rails, and am
wondering what other think is the best approach for my particular
application.

The application is in it’s own module namespace. To use it within
rails you just require it in application.rb and instantiate a class to
call methods on. It’s also well suited to be used from other various
applications though. The simplest way I could think of to make my
application work inside and outside of rails without much user
intervention would be something like this.

require ‘activerecord’
if ENV and ENV.has_key?(‘RAILS_ENV’)
require ‘models/mymodel’
ActiveRecord::Base.establish_connection()
end

I’d probably use a yaml file to store the database configuration like
rails does.

Any better ideas?

On 3/3/07, snacktime [email protected] wrote:

Argh that should have been:
unless ENV and ENV.has_key?(‘RAILS_ENV’)