Skip to content

Instantly share code, notes, and snippets.

@cqfd
Created October 21, 2010 02:19
Show Gist options
  • Save cqfd/637811 to your computer and use it in GitHub Desktop.
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
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