Challenge 3: Reading a DATABASE_URL — Solution # config/database.yml production: adapter: postgresql url: <%= ENV["DATABASE_URL"] %> pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %> =begin Notes: - url: <%= ENV["DATABASE_URL"] %> reads the entire connection string (host, port, username, password, database name all encoded together) from one environment variable, rather than hardcoding any of those values into the checked-in database.yml file -- the hosting provider (Heroku, Render, etc.) sets this variable automatically when a database add-on is provisioned. - ENV.fetch("RAILS_MAX_THREADS", 5) reads the pool size from its own environment variable if one is set, but falls back to a sensible default of 5 if it isn't -- fetch with a default argument, the same pattern Ruby's Hash#fetch already covered, applied here to ENV specifically. - Sizing the connection pool to match the app server's thread count (rather than picking an arbitrary number) avoids two failure modes: threads sitting idle waiting for a connection that's smaller than the pool needs, or the database itself being overwhelmed by more open connections than it can handle. =end