-
-
Save duncanbeevers/1503770 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| module SessionsHelper | |
| def sign_in(user) | |
| cookies.permanent.signed[:remember_token] = [user.id, user.salt] | |
| self.current_user = user | |
| end | |
| def current_user=(user) | |
| @current_user = user | |
| end | |
| def current_user | |
| @current_user ||= user_from_remember_token | |
| end | |
| # From a tutorial, why wouldn't current_user= be defined as self.current_user= or why isn't self.current_user = user , current_user = user. |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If
self.current_userwere implemented like so:Then you would have an infinitely-recursing method, no bueno.
And if you had this:
Then you would only be assigning
current_useras a local variable within that method.