I was approached by a collegue the other day to create an application with only one function. Having fallen out of love with Rails and its baggage I decided that my micro app needed a micro framework. Thinking that I wanted to get my feet wet with merb I started experimenting a bit. I didn't need a lot of things including a db. One of the beauties of merb is that you can pick or in this case not pick the ORM of your choice. So, with that in mind I tried a flat merb app. Here's the summary that the command line tool spits out, "all code in one file except for config files and views, something in-between Sinatra and a "regular" Merb application". This also give you the option to pick 'none' for ORM. merb-gen flat --orm=none flat-app
This explanation of what I was creating lead me to think I needed less than merb to kill this bird. A friend of mine Bruce recently did one of these one-trick-pony apps with Sinatra called frth (There is a really interesting story behind the app that you can read all about on his blog).
The Wonderful World of Sinatra
First on the list install it:
sudo gem install sinatra
The controller is a single file with a single method:
require 'sinatra' get '/' do "Hello World!" end
Want a view? Add 'filename.erb' to a new 'views' subdirectory and change controller file to:
1 | get '/' do |
What's great here is not that there's nothing to it, but that the complexity is so low at entry. As you go along you can add features and familiar mechanisms as you go along. I think for learning a framework this great. You can see everything and how it works as you assemble your app.
I also added in a rack config to run on thin.
The Feed
Now onto creating a feed in sinatra
sudo gem install builder