当前位置: 首页 > 工具软件 > Devise > 使用案例 >

Devise Session

松元明
2023-12-01

I am developing a Rails3 application and Devise for authentication. In the course of the workflow, I am storing information in the session, like patient_id. But, when the user log's out, I need to clear the session. I could've done it if I has control of user login and logout. But, now devise handles it.

How could I do it?

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.

In devise, many of the pages that teach how to accomplish certain things require editing a sessions controller. I set up devise using this https://github.com/fortuity/rails3-subdomain-devise/wiki/Tutorial-(Walkthrough) It didn't go over making a sessions controller. How do I make one. (If it's really easy i'm sorry, just give me the few simple steps)


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.



 类似资料:

相关阅读

相关文章

相关问答