---
title: 'Video: Sinatra At Boston.rb, Part 1'
teaser:
tags: news,web,sinatra,ruby
author: Dan Croak
published_on: 2009-10-16
---

This the first in a series of short videos. They feature Blake Mizerany
discussing Sinatra and Heroku in great technical detail at September's
[Boston.rb](http://bostonrb.org).

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="370"
  id="viddler_tbot_6">
  <param name="movie" value="http://www.viddler.com/player/e9e9aaf/" />
  <embed src="http://www.viddler.com/player/e9e9aaf/" width="437" height="370"
    type="application/x-shockwave-flash" />
</object>

Blake Mizerany wrote Sinatra in 2006 because he was working on a high traffic
site with a lot of POSTs, PUTs, and DELETEs. GETs can be cached but the others
cannot.

In this video, Blake discusses the following concepts as they apply to Sinatra:

## Backing Into Patterns

Start with a string, start with a text file, use `main` on Ruby. Move up to
Factories and Model-View-Controller and ActiveRecord when you need it.

Rails creates 72 files when you run the `rails` command. Blake decided he didn't
need to start with <abbr title="Model View Controller">MVC</abbr> on each new
project.

## Clean Routing System

Blake uses Sinatra often for web services. He compares Rails' `respond_to` with
Sinatra's `content_type` declaration.  He discusses his feeling that the routing
systems in other frameworks are overly complex undesirable.

    get '/users.json' do
      content_type :json
      @user = User.find(params[:id])
      @user.to_json
    end

His first example, shown above, highlights Sinatra's clean content type approach.

## Next

In the [next
video](https://thoughtbot.com/blog/post/215237920/sinatra-at-boston-rb-part-2),
Blake discusses:

* handling the `Accepts` header using Rack middleware
* deciding between Rack and Sinatra
* rack-hoptoad
* routing tricks such as passing wildcard params into block variables and
  non-greedy matching
