I don’t understand when and what calls this function:
def current_user
@current_user ||= user_from_remember_token
end
it’s from: http://ruby.railstutorial.org/chapters/sign-in-sign-out#code:current_user_working
When it kick in?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A little higher up you’ll see this:
This means that
current_useris available in all your controllers and all your views. So any time you need to know who the current user is for access control, filtering data, assigning a creator to a new object, put their name in the upper right corner of the page, etc. you can askcurrent_user.