From cd8ccdaf267357e35423ec2a9f7e38ec6b790e14 Mon Sep 17 00:00:00 2001 From: Katsuya HIDAKA Date: Thu, 14 Nov 2024 16:07:53 +0900 Subject: [PATCH 2/2] Load and process ERB only when database.yml contains ERB syntax for adapter setting --- Gemfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Gemfile b/Gemfile index 9eae364f8..e30c5cb7e 100644 --- a/Gemfile +++ b/Gemfile @@ -55,6 +55,13 @@ end database_file = File.join(File.dirname(__FILE__), "config/database.yml") if File.exist?(database_file) database_config = File.read(database_file) + + # If database.yml contains ERB syntax for adapter setting, process it through ERB. + if database_config.match?(/^ *adapter: *<%=/) + require 'erb' + database_config = ERB.new(database_config).result + end + adapters = database_config.scan(/^ *adapter: *(.*)/).flatten.uniq if adapters.any? adapters.each do |adapter| -- 2.44.0