Fun with Sinatra, Heroku and MongoDB

06 12 2009

I’ve been toying around with the idea for a small website lately, but never actually got around to do it. In an attempt to clear out my personal to do list I finally motivated myself to start yesterday, and I have to say the following combination of tools is not only insanely efficient, but also really fun to work with:


  • Sinatra, “a DSL for quickly creating web applications in Ruby with minimal effort”. I recommend using it in combination with Mongrel, Shotgun and Haml.

  • Heroku, a Ruby cloud hosting platform. Small sites are for free and Heroku’s git-based workflow just feels so natural. You can also manage your gem dependencies and set up environment variables, which made my life a whole lot easier.

  • MongoDB, “a scalable, high-performance, open source, schema-free, document-oriented database”. In this specific case I used MongoHQ for the database hosting, since they were nice enough to provide me with a beta account. I stored all the connection information for MongoHQ in environment variables as described above:


With this combination I was able to go from zero to mostly finished (I still need to write some of the content and make/steal a stylesheet) in very little time, while actually having fun! Thanks everybody for providing the Ruby community which such awesome tools! :-)


Rock-paper-scissors in Sinatra

27 03 2009

Just a stupid little example to demonstrate why Sinatra is cool:

The app is deployed on Heroku, have fun: http://rps.heroku.com/


My way: Ruby, Sinatra, Heroku

25 03 2009

RubyLearning just had a nice one week introductory course on Sinatra, a DSL for easily creating web applications. The next batch will start on May 2nd (and I’ll probably be around as a mentor again), you can join here if you are interested.

Anyway, since it’s so easy to write applications with Sinatra, you probably don’t want to waste time deploying them. That’s where Heroku comes into play, a Ruby hosting platform which modeled it’s workflow around git. In my – still somewhat limited – experience working with Heroku is painless and feels very natural, kudos to the team for providing us with such a nice option for hosting Rack based apps! In fact I liked Heroku so much, that I wrote a patch for Aaron Quint‘s sinatra-gen which will initialize git and create your app on Heroku for you. It’s not in the main branch yet, but Aaron said he likes the idea and that he will include it. Up until then you can get my version from here.

Update: Said patch – in slightly modified form – is now part of mainline sinatra-gen, so I recommend getting the “official” version, not mine.

Oh yeah, once you are done creating all this shiny new webapps in Sinatra, don’t forget to take some snapshots of them with snapurl, another nifty little app I recently wrote a small patch for.