Project

General

Profile

Defect #41749 » 0002-Load-and-process-ERB-only-when-database.yml-contains-ERB-syntax-for-adapter-setting.patch

Katsuya HIDAKA, 2024-11-14 08:09

View differences:

Gemfile
55 55
database_file = File.join(File.dirname(__FILE__), "config/database.yml")
56 56
if File.exist?(database_file)
57 57
  database_config = File.read(database_file)
58

  
59
  # If database.yml contains ERB syntax for adapter setting, process it through ERB.
60
  if database_config.match?(/^ *adapter: *<%=/)
61
    require 'erb'
62
    database_config = ERB.new(database_config).result
63
  end
64

  
58 65
  adapters = database_config.scan(/^ *adapter: *(.*)/).flatten.uniq
59 66
  if adapters.any?
60 67
    adapters.each do |adapter|
(2-2/2)