ActiveRecord代码库中的哪一行(或方法)是否加载了Rails应用程序的config /
database.yml? (我具体看4.0.5,但是如果有人有关于> = 4.0.5的任何信息,那会很有启发性)?
解决方法
它位于Railties中,特别是在第101-116行的文件railties / lib / rails / application / configuration.rb中(对于Rails 4.0.5):
https://github.com/rails/rails/blob/v4.0.5/railties/lib/rails/application/configuration.rb#L101-L116
# Loads and returns the configuration of the database. def database_configuration yaml = paths["config/database"].first if File.exist?(yaml) require "erb" YAML.load ERB.new(IO.read(yaml)).result elsif ENV['DATABASE_URL'] nil else raise "Could not load database configuration. No such file - #{yaml}" end rescue Psych::SyntaxError => e raise "YAML Syntax error occurred while parsing #{paths["config/database"].first}. " \ "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \ "Error: #{e.message}" end