我想使用 Rack 中间件打印模板正文。下面是我的设置...
#config/initializers/response_timer.rb
class ResponseTimer
def initialize(app)
@app = app
end
def call(env)
status, headers, response = @app.call(env)
[status, headers, response.body]
end
end
#application.rb file
config.middleware.use "ResponseTimer"
当我提出请求域名/学生/时,我遇到了错误。
undefined method `each' for #<String:0xd69a2e0>
请帮忙。
最佳答案
我通过将 [status, headers, response.body] 更改为 [status, headers, [response.body]] 来解决我自己的问题,将 response.body 放在数组中。
关于ruby-on-rails-3 - rails 3 rack 中间件问题,未定义方法 `each',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17784958/