Alex Rivera | Logout

Ruby strings with embedded variables

Asked 2012-05-31T14:01:43.993
9

How can I store ruby string with embedded variables in yaml, but insert variable values only when I get string from yaml?

Edit
Report

1 Answer

2

Embed erb in yaml file as rails did:

# config/initializers/load_config.rb
APP_CONFIG = YAML.load_file("#{Rails.root}/config/app_config.yml")[Rails.env]


# config/app_config.yml
development:
  key1: <%= # ruby code ... %>
test:
  key1: <%= # ruby code ... %>
production:
  key1: <%= # ruby code ... %>
answered 2012-05-31T14:25:14.760

Your Answer