I have a background process that modifies records in a database. The models connect to the database using something like this:
dbconfig = YAML::load(File.open(\'
I would set up the connection once at the start of your background process. Once you've established the connection once, all of the models will work correctly anyway.
Your connection establishment code would look something like this:
@environment = ENV['RACK_ENV'] || 'development'
@dbconfig = YAML.load(File.read('config/database.yml'))
ActiveRecord::Base.establish_connection @dbconfig[@environment]