Deployment database config

We set the database connection configuration in the database.yml file. This is convenient in development environment. But in production, we would better put the database connection and secret out of the database configuration file. We can do that by putting the value in environment variable and use ENV to access them.

 2  adapter: postgresql
 3  encoding: unicode
 4  pool: 5
 5  database: <%= ENV['APP_DATABASE'] %>
 6  username: <%= ENV['APP_USERNAME'] %>
 7  password: <%= ENV['APP_PASSWORD'] %>
 8  host: <%= ENV['APP_HOST'] %>
 9  port: <%= ENV['APP_PORT'] %>

What’s next? We’re going to take a look at “Introducing git”.

overlaied image when clicked on thumbnail

Makzan | Ruby on rails 101 | Table of Content