有人可以指向我在启动时读取database.yml文件以连接到数据库的代码。我正在使用Rails 2.3.3
感谢, 灰
答案 0 :(得分:0)
它在lib / initializer.rb中加载(在rails 2.3.5的第900行附近):
# Loads and returns the contents of the #database_configuration_file. The
# contents of the file are processed via ERB before being sent through
# YAML::load.
def database_configuration
require 'erb'
YAML::load(ERB.new(IO.read(database_configuration_file)).result)
end