I have a terrible understanding of understanding the assignment function that is required, as described in chapter 8.2.3 . Hartl tutorial.
As a context, it focuses on the second line of the following sign_in function:
def sign_in(user) cookies.permanent[:remember_token] = user.remember_token self.current_user = user
Where does he mention, because its purpose, it should then be separately defined as
def current_user=(user) @current_user = user end
If the current_user= method current_user= explicitly designed to handle assignment before current_user . My perplexity:
Why is this even necessary? I thought simple = would allow you to assign things. For example user.email = hello@kitty.com
Also, when in the end it will be code redirect_to current_user , how does what belongs to SessionsController translate into a view controlled by UsersController ?
Thanks!!
source share