我正在为需要有条件地设置 cookie 的 rails 应用程序编写机架中间件组件。我目前正试图弄清楚设置cookies。从谷歌搜索看来,这应该可行:
class RackApp
def initialize(app)
@app = app
end
def call(env)
@status, @headers, @response = @app.call(env)
@response.set_cookie("foo", {:value => "bar", :path => "/", :expires => Time.now+24*60*60})
[@status, @headers, @response]
end
end
它不会给出错误,但也不会设置 cookie。我究竟做错了什么?