当从页到页导航时,如何保持当前设计会话不被自动销毁? [英] How do I keep the current devise session from being destroyed automatically when navigating from page to page?
问题描述
我已经看过关于devise的current_user的帖子,但是他们都没有解决我的问题。我可以从我的rails 3视图(erb文件)访问current_user,但是无法在控制器中访问它。
I've looked through the posts about devise's current_user, but none of them solve my problem. I can access current_user from my rails 3 views (erb files), but can not access it in the controller.
<%= current_user.name %>
在erb中工作。
@user = current_user
在控制器中不起作用。我缺少什么?
does not work in the controller. What am I missing?
---------编辑------
---------edited------
我作为价值不如零。原来我可以使用
I am getting nil as value. It turns out I am able to use
@user = current_user
在我的索引控制器,但一些如何一旦它去一个不同的动作(如创建)会话被销毁。
in my index controller, but some how once it goes to a different action (like create) the session is destroyed.
所以现在真正的问题是:
So the real question now is:
如何保持当前用户从页面登录到页面?
How do I keep the current user signed in when going from page to page?
推荐答案
最后弄清楚问题是什么:需要从
Finally figured out what the problem was: needed to get a fixed rails.js file from
https://github.com /fermion/jquery-ujs/blob/master/src/rails.js
非常感谢@Patrick Connor链接到他的答案
Many thanks to @Patrick Connor link to his answer
这篇关于当从页到页导航时,如何保持当前设计会话不被自动销毁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!