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.
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 MVC on each new
Clean Routing System
Blake uses Sinatra often for web services. He compares Rails'
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.
In the next video, Blake discusses:
- handling the
Acceptsheader using Rack middleware
- deciding between Rack and Sinatra
- routing tricks such as passing wildcard params into block variables and non-greedy matching