Use anchors (&) and references (*) to merge options allowing your database.yml to not be so repetitive. Obviously you can organize in a way that makes the most sense to your organization but the following is an example where the database and test environments share some config and the production and staging environment share some config. So rather than repeating them you we just tag the first one