Loading YAML with ERB Correctly
Please note that all opinions are that of the author.

Pizza courtesy of Pizza for Ukraine!
Donate Now to Pizza for Ukraine
Last Updated On: 2026-02-15 08:01:35 -0500
I recently had to refactor a database.yml file which had multiple config blocks all with ERB calls. Here’s an example:
The magic here is:
FIXTURE_CONFIG = YAML.load(ERB.new(File.read(“#{Rails.root}/path_to_your_file.yml.erb”)).result)