Open 1-alex98 opened 4 years ago
Good catch--I agree you're correct. The code you suggest is one way to fix it. However, there are multiple settings in the app that may need to be overridden, including basically everything in the database.yml and secrets.yml files.
A better solution may be to use an erb expression in the yaml instead, so that any value can be conditionally overridden using ENV settings. For example:
development:
adapter: mysql2
database: <%= ENV["DB_DATABASE"] || 'codeworkout' %>
username: <%= ENV["DB_USERNAME"] || 'codeworkout' %>
password: <%= ENV["DB_PASSWORD"] || 'codeworkout' %>
host: <%= ENV["DB_HOST"] || 'localhost' %>
This is supported in database.yml ... but would need to check on secrets.yml. With this change, the code itself would be unchanged and all the ENV support would go through the config file(s).
So it needs to be renamed .yml.erb right?
No, ERB notation is supported directly in the file and the extension does not have to be changed. (From docs, but not tested :-).)
The DB options in the docker-compose file seem to have no effect on the connection parameters of the application instead only the config/database.yml is respected.
How would this be corrected? Like this? puma.rb: