Created
October 21, 2010 02:19
-
-
Save cqfd/637811 to your computer and use it in GitHub Desktop.
Some sample code to illustrate that current_user = foo doesn't set @current_user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sign_in(user) | |
cookies.permanent.signed[:remember_token] = [user.id, user.salt] | |
current_user = user | |
# self.current_user = user will work though | |
raise "#sign_in --> @current_user is still nil" unless @current_user == user | |
# gross hack; otherwise the method returns nil since raise would be last line | |
user | |
end | |
def sign_out | |
cookies.delete(:remember_token) | |
current_user = nil | |
# self.current_user = nil will work though | |
raise "#sign_out --> @current_user isn't nil" unless @current_user == nil | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment