I\'d like to be able to push code to dev.myapp.com for testing and then to www.myapp.com for production use. Is this possible with Heroku?
Things are easier now. Here's how you do it...
$ heroku create myapp --remote production
$ heroku create myapp-staging --remote staging
This will create named remote repos for each app, which you can see in .git/config.
You can now use either the --app or --remote switches to target a particular app:
$ heroku info --app myapp-staging
$ heroku info --remote staging
For Rails apps, Heroku defaults to the "production" environment. If you want your staging app to run in a staging environment, create the environment in your project and set the corresponding RAILS_ENV and RAKE_ENV environment variables on the app:
$ heroku config:set RACK_ENV=staging RAILS_ENV=staging --remote staging
If you have other configuration variables you'll need to pass them in for each environment as well.
$ heroku config:set AWS_KEY=abc --remote staging
$ heroku config:set AWD_SECRET=123 --remote staging
...etc
That's a huge pain though so I just use my snappconfig gem and run
$ rake heroku:config:load[myapp-staging]
to load my project's YAML config files into Heroku.
Now you just push to Heroku like this:
$ git push staging master
$ git push production master
and migrate like this:
$ heroku run rake db:migrate --remote staging
$ heroku run rake db:migrate --remote production
(See Managing Multiple Environments for an App | Heroku Dev Center for more info and shortcuts.)