I am going through the great Michael Hartl tutorial to build ruby app here.
I am trying to understand the concept of how to create a session and I am stuck in understand
The method def current_user=(user)
is basically a setter that the sign_in method uses in order to set the current_user.
def current_user
will return the @current_user or if it is not set it will find it in the Users table by the remember_token. This basically allows you get the current_user at any point in time.
self.current_user
in the context of the sign_in method will refer to the calling class or module in this case. It will be calling current_user
from the Session Helper
module.