Reputation: 527
Have configuration in aws_setting.yml for different environments, as:
local: &local_settings
enable_setting: true
heroku: &heroku_settings
enable_setting: <%= ENV['MY_SETTING'] %>
test:
<<: *local_settings
development:
<<: *local_settings
staging:
<<: *heroku_settings
In heroku added MY_SETTING kvp in staging's Config Vars
Loaded settings during initialization:
S3_SETTING = YAML.load_file("#{::Rails.root}/config/aws_setting.yml")[Rails.env]
Now after deployment to staging, instead of getting value for S3_Setting['enable_setting']
as true
or false
, receiving '<%= ENV['MY_SETTING'] %>' as text.
Upvotes: 0
Views: 45
Reputation: 32627
This is because you're just loading YAML. You also need to parse the content as ERB to get the value extrapolated.
YAML.load(ERB.new(File.read("#{::Rails.root}/config/aws_setting.yml")).result)[Rails.env]
Upvotes: 1