Project

General

Profile

How to use encrypted database credentials » Gemfile.patch

Jan Catrysse, 2024-09-29 09:09

View differences:

Gemfile (revision 277728afc979a7123eef8d1a8ac54d74c235c5fc) → Gemfile (date 1727590462090)
61 61
require 'yaml'
62 62
database_file = File.join(File.dirname(__FILE__), "config/database.yml")
63 63
if File.exist?(database_file)
64
  yaml_config = ERB.new(IO.read(database_file)).result
64
  yaml_config = ERB.new(IO.readlines(database_file).reject { |line| line =~ /<%.*%>/ }.join).result
65 65
  database_config = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(yaml_config) : YAML.load(yaml_config)
66 66
  adapters = database_config.values.filter_map {|c| c['adapter']}.uniq
67 67
  if adapters.any?
    (1-1/1)