我尝试设置cookie和渲染模板。 Cookie有效,但模板不起作用。我收到了:
<pre style="word-wrap: break-word; white-space: pre-wrap;"></pre>
我做错了什么?
class Racker
def self.call(env)
new(env).response.finish
end
def initialize(env)
@request = Rack::Request.new(env)
end
def response
case @request.path
when '/new_game'
Rack::Response.new do |response|
response.set_cookie('name', @request.params['name'])
render('new_game')
end
...
end
end
def render(template)
path = File.expand_path("./views/#{template}.html.erb")
ERB.new(File.read(path)).result(binding)
end
end