Heroku Deploy with Rails App

With my recent rails project at the Flatiron School, I deployed to heroku and learned a few cool things.

I found this video extremely helpful for the deploy, and set up of postgres (and you get a funny blooper at the end!):

Really useful advice I was given with heroku was to deploy early, and frequent so any bugs can be fixed as they happen instead of having to figure them out and make major changes because the bug is so embedded in the app that was working locally.

If you don’t want things going live immediately you can add a staging environment – https://devcenter.heroku.com/articles/multiple-environments.

You run heroku rake db:migrate, heroku rake db:seed to set up your database and seed your data.

You cannot drop a database in heroku, like you would in rails so you need to do heroku pg:reset

To drop into the rails console run: heroku run rails console. I found this super helpful to edit existing data in my databases, and run database queries.

You can set up configed vars for private keys and the like:

$ heroku config:set GITHUB_USERNAME=joesmith
Adding config vars and restarting myapp... done, v12
GITHUB_USERNAME: joesmith

$ heroku config
GITHUB_USERNAME: joesmith
OTHER_VAR:    production

$ heroku config:get GITHUB_USERNAME
joesmith

$ heroku config:unset GITHUB_USERNAME
Unsetting GITHUB_USERNAME and restarting myapp... done, v13

https://devcenter.heroku.com/articles/config-vars

And of course you’ll need to run heroku logs when you need to troubleshoot why something is not working as you’d expect.

UPDATE:  I just switched to a new computer and heroku did not recognize git push heroku master. It threw this nasty error at me:

fatal: ‘heroku’ does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Here’s the fix! heroku git:remote -a <yourapp> 

Then all works fine!

 

Happy Deploying!

 

Copyright Loving to Code 2025
Tech Nerd theme designed by Siteturner