From 23f71c431dae9ec389a861700ea84c7b0cbf913c Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Sun, 14 Nov 2010 05:12:01 -0500 Subject: corrected sample code to clear @_current_user class variable also --- railties/guides/source/action_controller_overview.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source/action_controller_overview.textile') diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile index c02e9f1912..3774c7fcf5 100644 --- a/railties/guides/source/action_controller_overview.textile +++ b/railties/guides/source/action_controller_overview.textile @@ -239,7 +239,7 @@ class LoginsController < ApplicationController # "Delete" a login, aka "log the user out" def destroy # Remove the user id from the session - session[:current_user_id] = nil + @_current_user = session[:current_user_id] = nil redirect_to root_url end end -- cgit v1.2.3 From f69784289b6efd0eabb674d6467b2cd0c0a4af07 Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Sun, 14 Nov 2010 05:20:10 -0500 Subject: added note with example for using flash in redirection --- railties/guides/source/action_controller_overview.textile | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'railties/guides/source/action_controller_overview.textile') diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile index 3774c7fcf5..cabc0c8a7f 100644 --- a/railties/guides/source/action_controller_overview.textile +++ b/railties/guides/source/action_controller_overview.textile @@ -261,6 +261,13 @@ class LoginsController < ApplicationController end +Note it is also possible to assign a flash message as part of the redirection. + + + redirect_to root_url, :notice => "You have successfully logged out" + + + The +destroy+ action redirects to the application's +root_url+, where the message will be displayed. Note that it's entirely up to the next action to decide what, if anything, it will do with what the previous action put in the flash. It's conventional to display eventual errors or notices from the flash in the application's layout: -- cgit v1.2.3 From abf225423cbe11fcb0460a40bd49263694eaef06 Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Sun, 14 Nov 2010 06:02:16 -0500 Subject: removed unnecessary indentation --- railties/guides/source/action_controller_overview.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source/action_controller_overview.textile') diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile index cabc0c8a7f..b39075f101 100644 --- a/railties/guides/source/action_controller_overview.textile +++ b/railties/guides/source/action_controller_overview.textile @@ -264,7 +264,7 @@ end Note it is also possible to assign a flash message as part of the redirection. - redirect_to root_url, :notice => "You have successfully logged out" +redirect_to root_url, :notice => "You have successfully logged out" -- cgit v1.2.3