开发者

How do I keep the current devise session from being destroyed automatically when navigating from page to page?

开发者 https://www.devze.com 2023-02-17 03:11 出处:网络
I\'ve looked through the posts about devise\'s current_开发者_JAVA百科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

I've looked through the posts about devise's current_开发者_JAVA百科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 %>  

works in the 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

Many thanks to @Patrick Connor link to his answer

Devise session immediately expiring on .js call [AJAX]

0

精彩评论

暂无评论...
验证码 换一张
取 消