Rob Conery の Tekpub/Rails 3 チュートリアル ビデオをフォローしています。ビデオ リリースの Rack のバージョン (1.1) と私のマシンの Rack のバージョン (1.4.5) の間で何かが変わったと思います。別の方法で何をする必要があるかを理解する方法がわかりません。
次のコードでは、文字列変数があり、それに文字列変数 (メソッドout
によって返される配列の 3 番目の要素) を連結しようとしています。MyApp.Call
class EnvironmentOutput
def initialize(app)
@app = app
end
def call(env)
out = ""
unless(@app.nil?)
response = @app.call(env)[2]
# The Problem is HERE (Can't Convert Array to String):
out+=response
end
env.keys.each {|key| out+="<li>#{key}=#{env[key]}"}
["200", {"Content-Type" => "text/html"}, [out]]
end
end
class MyApp
def call(env)
["200", {"Content-Type" => "text/html"}, ["<h1>Hello There</h1>"]]
end
end
use EnvironmentOutput
run MyApp.new
しかし、私はエラーが発生します:
"Can't Convert Array to String" at `out+=response`
ここで何が欠けていますか?