title: Rack Routing - NoMethodError
body: <p>I'm trying to set up a basic routing system in Rack, however.. I can't understand why the first route ('/') works, and the second ('/help') doesn't. What gets returned in the case of '/help' is a NoMethodError. Why is that, and how can I fix it? Thank you.</p>
  
  <pre><code>require 'rack'
  
  class MyApp
    def self.call(env)
      new.call(env)
    end
  
    def self.get(path, &amp;block)
      @@routes ||= {}
      @@routes[path] = block
    end
  
    def call(env)
      dup.call!(env)
    end
  
    def call!(env)
      @req = Rack::Request.new(env)
      @res = Rack::Response.new
      @res.write route(@req.path)
      @res.finish
    end
  
    def route(path)
      if @@routes[path]
        @@routes[path].call
      else
        'Not Found'
      end
    end
  
    def to_do(arg)
      arg
    end
  end
  
  MyApp.get '/' do
    'index'
  end
  
  MyApp.get '/help' do
    to_do 'help'
  end
  
  run MyApp
  </code></pre>