如何使用会话在rails控制台中发送请求?
我知道我可以使用 app.get
和 app.post
在 Rails 控制台中测试控制器。
但是如何设置会话
呢?我发现有app.session
,但它似乎没有保留其状态。
$ app.session[:a] = "123"
$ app.get "/"
$ app.session
=> {}
I know I can use app.get
and app.post
to test controller in Rails console.
But how to set the session
? I found there is app.session
, but it seems not to preserve its status.
$ app.session[:a] = "123"
$ app.get "/"
$ app.session
=> {}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您将 RedisStore 用于 Rails 会话,则可以使用以下方便的方法在给定会话 ID 的情况下检索会话
If you are using RedisStore for your Rails sessions, you can retrieve a session with the following handy method given a session id
这是一篇博客文章 关于它。从它的乏味程度来看,我猜测人们通常不会这样做。
Here's a blog post about it. Judging by how tedious it is my guess is that people usually don't do this.