Standalone ActiveRecord application can't find ActiveRecord

I need a standalone script to load models every two hours from an
external source. I copied code from the original Ruby on Rails (RoR)
application that works fine. The problem is that on my system, even
the simplest request produces an error: it can’t find ActiveRecord.

Here’s the simplified script:
#!/usr/bin/env ruby
require “rubygems”
gem “activerecord” #new version of ‘gem_require’
ActiveRecord::Base.establish_connection(:adapter =>
‘mysql’, :database => ‘sample’,
:username => ‘root’, :password => ‘pass’, :socket => ‘/tmp/

Here’s the output:
ruby -w sample.rb
sample.rb:5: uninitialized constant ActiveRecord (NameError)

I get the same result putting the same code into irb.

But when I modify the last line of the script to simply “puts
$:” (i.e., print the list of loaded modules), here’s the list:

So ActiveRecord is sitting there. What am I doing wrong??
—Jim Gagne—

On 26 Oct 2007, at 22:18, Jim Gagne wrote:

gem "activerecord"             #new version of 'gem_require'


require “rubygems”
require “active_record”