From: Xeno Campanoli Date: 2008-05-29T08:25:14+09:00 Subject: Mystified by a YAML/AR interaction...???? I've got the following sequence which when run interactively yields a working connection to my Active Record ORM where I can get data: env = 'production' dbymlspec = "#{RAILSBASEDIR}/config/database.yml" conf = YAML::load(dbymlspec) STDERR.puts "trace conf: #{conf}" STDERR.puts "trace conf.class: #{conf.class}" STDERR.puts "trace conf[#{env}]: #{conf[environment]}" STDERR.puts "trace conf[#{env}].class: #{conf[environment].class}" if conf then ActiveRecord::Base.establish_connection(conf[environment]) else puts "YAML::load returned false on dbymlspec: #{dbymlspec}" end ----snip---- But the output to STDERR is: trace conf: /home/rotw/bnsf/config/database.yml trace conf.class: String trace conf[production]: trace conf[production].class: NilClass So the establish_connection method shouldn't be seeing anything but a nil. What's going on here? How come establish_connection sees the database, and what is the magic here?