- What’s the best practice for configuring services that notify users between development, staging and production? You really don’t want to send out a million email notifications by mistake when you are testing the staging version of a service. If you put the switch in the database, it could lead to the production database being moved to staging or development and sending out erroneous notifications. Putting the switch in an environment variable means that it’s difficult to test the staging server with some sample data.
Some projects encrypt credentials for the different environments with different keys, thus the production credentials will absolutely not be available to the staging servers. (This can be hassle because you get exceptions when you try to use the real credentials in a staging environment with the different key.) Doing this means that you can inject test data into the staging environment encrypted with the staging keys and use that without risk of mistakenly sending notifications to real users.
Consider wrapping the API in question with a fake that only talks to the real world in the production environment.
Perhaps you could set up a rake task that manages the state of a live versus test notification.