Making a Simple, Database-Driven Website with Sinatra and Heroku

When I want to make a website, my instinct is to use Rails.  However, sometimes I don’t need everything (or even 50%) of what Rails provides and it feels like a waste for a quick project.  Sinatra may be the simplest web framework ever, but it is also incredibly powerful.  Combined with Heroku, anyone with a little coding experience can have a website running for free in just a few minutes.

There are plenty of good Sinatra tutorials on the web, however I have found that most of them focus on static content.  For those that don’t, I’ve found that very few will also cover how to integrate Sinatra with Heroku Postgres and get your app up and running in the cloud. After having to do so myself earlier this week, I thought it would be useful to others if I posted a quick and to the point article about how to get Sinatra and ActiveRecord up and running on Heroku.  All of the code that follows is available on my GitHub, right here.  In this tutorial you’ll notice that I bold all filenames and shell commands, this is just for readability and you’re free to ignore it.

Continue reading