I have an array of ENV variables defined as below in my .env
file:
WEBHOOK_SIGNATURES=
-value_1
-value_2
-value_3
I also have an external_service.yml
custom configuration file to which I would like to add this array of values so I can access them via Rails.configuration.x.external_service.webhook_signatures
instead of ENV["WEBHOOK_SIGNATURES"]
default: &default
webhook_signatures: <%= ENV['WEBHOOK_SIGNATURES'] %>
production:
<<: *default
development:
<<: *default
test:
<<: *default
The problem is that Rails.configuration.x.external_service.webhook_signatures
is returning nil
.
Is there a proper way to define an array of values for a custom configuration file?
EDIT: In the end I defined it in the external_service.yml
file as follow:
webhook_signatures: <%= ENV['WEBHOOK_SIGNATURES']&.split(',')&.map(&:strip) %>
It works, effectively converting the multiline variable in the .env to an array of values available using Rails.configuration.x.external_service.webhook_signatures
.
If there's a better, less nasty way I'd appreciate the insight.