Ruby and Rails development of Heroku sites

I’ve been working on a live project recently and found it necessary to see what was happening on the Heroku version as it was running differently from my development machine. Saying ‘it works on my machine’ doesn’t help the people trying to use the site, so I had to delve deeper and work out a routine to ensure I was both finding the problem, and also fixing it correctly.

Oh, it goes without saying, try to get Postgresql running on your dev machine.

The short answer is to use something like the following steps when developing sites to run on Heroku:

a) get code with tests working – be sure to use capybara as this will save you hours of time as you repeatedly run the tests. For this project I was spending about 30 seconds running through a number of tests on the site to see that pages loaded correctly, and forms did what they should do too. Running them by hand would’ve taken at least 15 minutes or longer each time, and I would be so board too.

b) pull down heroku db and add to postgres using pg:pull command
https://devcenter.heroku.com/articles/heroku-postgresql#pg-pull which means you can pull down the postgresql database and install it into your locally running one and then swap out your ‘dev’ database to use this one and see what’s missing, or whatever.

c) add anything new there to file that loads your test, and/or live data into the database.

d) check all runs ok on dev with db from heroku

e) when ok, then load your data into test database

f) upload to heroku – including db data if necessary checking with heroku logs command as needed. This lets you see what fell over and wasn’t running as expected.

Leave a Reply

Your email address will not be published. Required fields are marked *