I want to populate my .yml file in config folder dynamically when my server is loading.
The following is an example of my .yml file
# Configuration Credentials
development: &development
user: "***"
password: "***"
test:
<<: *development
non-prod:
user: "***"
password: "***"
production: &production
user: "***"
password: "***"
I want to set the value for each key in the form of embedded ruby like this:
development: &development
user: <%= get_value_for(user) %>
password: <%= get_value_for(password) %>
I want to load the .yml file when the server is about to run.
I want to know where should I define the get_value_for method so I can call it inside my yml file? (probably in application.rb but I do not know how exactly)
Create a custom class and define the method their. Then require the class inside
config/application.rbInside
config/application.rbInside
config/database.yml