Use ERB in env file?
benlieb opened this issue · comments
Benjamin Lieb commented
Is there any way to parse this first with ERB (using Rails)?
Similar to how yml files work:
url: <%= ApplicationConfig.defaults("REDIS_URL") %>
channel_prefix: threadable_api_production
Grant Shangreaux commented
i've been using yml
files with config_for(:the_thing)
to get the ENV files into rails
# config/the_thing.yml
shared:
base_url: <%= ENV["BASE_URL"] %>
admin_password: <%= ENV["ADMIN_PASSWORD"] %>
does this get you what you need? rather than trying to run ruby and interpolate in the .env
file
Benjamin Lieb commented
@gcentauri I referenced yml files in my question…
Brandon Keepers commented
@benlieb there is not erb+yaml support built into dotenv, but you could pretty easily load the file yourself:
Dotenv.update YAML.load(ERB.new(Dotenv::Rails.root.join('.env.yml').read).result)