diff options
author | Rafael Barbolo <barbolo@gmail.com> | 2018-04-23 14:50:59 -0300 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2018-04-23 13:50:59 -0400 |
commit | 80cbf19453bb3fe22e8d038a9631b8436320788b (patch) | |
tree | 0df0d2f1630bc531dde405f1e5f5c1fd2916fdc5 /guides/source | |
parent | cde7c30781e45dab23ff6be8d5b83b3c67344b64 (diff) | |
download | rails-80cbf19453bb3fe22e8d038a9631b8436320788b.tar.gz rails-80cbf19453bb3fe22e8d038a9631b8436320788b.tar.bz2 rails-80cbf19453bb3fe22e8d038a9631b8436320788b.zip |
Remove key from session by using session.delete (#31685)
* Remove key from session by using session.delete
You are not deleting a key from session when you assign nil to that key.
* Update guides on how to destroy a user session
In this commit, the user id is removed from session and controller's variables related to the user are nullified.
[Rafael Mendonça França + Rafael Barbolo]
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/action_controller_overview.md | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index e0e85588a0..4e3319dec4 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -457,7 +457,9 @@ class LoginsController < ApplicationController # "Delete" a login, aka "log the user out" def destroy # Remove the user id from the session - @_current_user = session[:current_user_id] = nil + session.delete(:current_user_id) + # Clear the memoized current user + @_current_user = nil redirect_to root_url end end |