Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
require 'sinatra/base' # The controller for the home page. class HomeController < ::Sinatra::Base get '/' do # <-- (1) slash "This is the home controller." end end # The controller for the documents section. class DocumentsController < ::Sinatra::Base get '' do # <-- (2) no slash "This is the documents controller." end end # The main application. It aggregates the different controllers using Rack::URLMap. class Application def initialize @app = ::Rack::URLMap.new( '/' => HomeController.new, '/documents' => DocumentsController.new ) end def call(env) @app.call(env) end end run Application.new # 1. Load http://localhost:9292/ # You’ll see the home controller message. # # 2. Load http://localhost:9292/documents # You’ll see the documents controller message. # # 3. Change "get ''" to "get '/'" and load http://localhost:9292/documents # You’ll get a 404 error.
This paste will be private.
From the Design Piracy series on my blog: