First the predispositions, i like to have my heroku git remotes set up as staging and production so you can easily use git push staging/production to deploy to each one of them. I'll be using that setup to explain how to make a staging env.
- create a
config/environments/staging.rb which you will copy off `config/environments/production.rb'
- add a database.yml entry for the staging database(not really needed for heroku but can't hurt)
- Backup your .env file (if you have it)
- Install heroku-config plugin by
heroku plugins:install git://github.com/ddollar/heroku-config.git
- pull your environment settings from heroku(production server) with
heroku config:pull --remote production
- make changes to the .env file and don't forget to add these values to the config:
RACK_ENV=staging RAILS_ENV=staging so it will use the staging environment configuration.
- fork a heroku environment with
heroku fork -a production staging (those are heroku appnames you want instead of production/staging)
- Do a `heroku config:push --remote staging'
- Be sure to deploy the code to staging env properly
You can also read this tutorial, i think i used it to get started with multiple envs on heroku:
https://devcenter.heroku.com/articles/multiple-environments#managing-staging-and-production-configurations