Heroku is a great web publishing platform. Additionally, Sinatra is a great ruby web framework. In this post, I’ll show you how to quickly combine the two.

I have created a sinatra-heroku-template app to make it easy on you. All files combined, it is only 20 lines of code.

Do the following to get it up and running.


git clone git://github.com/scottmotte/sinatra-heroku-cedar-template.git
gem install bundler
bundle
heroku create yourwebapp
git push heroku master
bundle exec heroku open

That’s it. You now have a bare bones Ruby app running in production on Heroku. Add your own code as necessary.

Here’s a breakdown the file structure:

  • app.rb defines your routes and is the core of your application
  • config.ru boots your app
  • Gemfile defines your library dependencies
  • Procfile instructs Heroku how to run your application on its platform

Additionally, you can run the application locally with the following commands

git clone git://github.com/scottmotte/sinatra-heroku-cedar-template.git
gem install bundler
bundle
bundle exec foreman

Visit localhost:5000 and you will see your application running.

Enjoy Sinatra and enjoy Heroku.



SendGrid Team
Expert advice and insight about all things email including best practices tips, examples, and advice for marketers, developers, and everyone in between.