Rails 3使用devise重置会话 [英] Rails 3 reset session using devise
问题描述
如何处理这种情况?
覆盖Devise :: SessionsController like this:
class SessionsController< Devise :: SessionsController
respond_to:html
def destroy
super
reset_session
end
end
不要忘记将设计视图移动到正确的位置(views / devise / sessions查看/会话),并修改设计路线以指向控制器。例如:
devise_for:users,:controllers => {:sessions => 会话}
请参阅github上的devise文档以获取更多详细信息或Bill发布的链接。 / p>
I am developing a Rails3 application using Devise for authentication. In the course of the workflow, data like patient_id is stored in the session. However, when the user log's out, the session needs to be cleared. I am unable to figure out how to reset session data since Devise handles users login / logout and I not having control over it.
How to handle this situation?
Overwrite Devise::SessionsController like this:
class SessionsController < Devise::SessionsController
respond_to :html
def destroy
super
reset_session
end
end
Don't forget to move the devise views to the right place (views/devise/sessions to views/sessions) and modify the devise route to point to your controller. For example:
devise_for :users, :controllers => { :sessions => "sessions" }
See the devise docs on github for more details or the link posted by Bill.
这篇关于Rails 3使用devise重置会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!