Can't generate AR from script (ActiveRecord::ConnectionNotEs

Generating ActiveRecord instances from the console works fine.

./script/console
Loading development environment.

Pim.new()
=> #<Pim:0xb74427dc @attributes={“vpimitem”=>nil}, @new_record=true>

But running this little script:

#!/usr/bin/env ruby
require File.dirname(FILE) + ‘/…/config/boot’
Pim.new()

Will spit out this:

/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:225:in
retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished) from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:inconnection’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:696:in
columns' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1969:inattributes_from_column_definition’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1351:in
initialize_without_callbacks' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/callbacks.rb:236:ininitialize’
from playground/importer.rb:3

I’ve tried both sqlite and mysql as database adapters and get the same
error
in both cases.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs