在哪里可以找到rails在引导时连接到数据库的代码

时间:2010-06-17 23:49:37

标签: ruby-on-rails

有人可以指向我在启动时读取database.yml文件以连接到数据库的代码。我正在使用Rails 2.3.3

感谢, 灰

1 个答案:

答案 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