aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorRafael Barbolo <barbolo@gmail.com>2018-04-23 14:50:59 -0300
committerRafael França <rafaelmfranca@gmail.com>2018-04-23 13:50:59 -0400
commit80cbf19453bb3fe22e8d038a9631b8436320788b (patch)
tree0df0d2f1630bc531dde405f1e5f5c1fd2916fdc5 /guides
parentcde7c30781e45dab23ff6be8d5b83b3c67344b64 (diff)
downloadrails-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')
-rw-r--r--guides/source/action_controller_overview.md4
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