I'm going through the tekpub rack tutorial but when I try to run even a basic program in rack i get this error.
ERROR Rack::Lint::LintError: Response body must respond to each
/Users/adam/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.3.4/lib/rack/lint.rb:19:in `assert'
/Users/adam/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.3.4/lib/rack/lint.rb:513:in `each'
/Users/adam/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.3.4/lib/rack/body_proxy.rb:23:in `method_missing'
/Users/adam/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.3.4/lib/rack/chunked.rb:23:in `each'
/Users/adam/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.3.4/lib/rack/handler/webrick.rb:71:in `service'
/Users/adam/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/adam/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/adam/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
This is the program im trying to run:
class EnvironmentOutput
def call(env)
["200",{"Content-Type" => "text/plain"}, "Hello World"]
end
end
run EnvironmentOutput.new
I'm a beginner programmer so I'm not sure whats going on. Tried google searches but nothing has come up.
Using ruby 1.9.3 Rack 1.1
Thanks
This is a change in Ruby 1.9.2 and, as has been suggested, if you surround your string with ["brackets"] it will turn "Hello World" into an array with a single value. Sounds silly, but that's the deal :).
It used to be that a String in Ruby would respond to each with an iteration of characters. Evidently there have been changes that way.