class ApplicationController < ActionController::Base
private
# Finds the User with the ID stored in the session with the key
# :current_user_id This is a common way to handle user login in
# a Rails application; logging in sets the session value and
# logging out removes it.
def current_user
@_current_user ||= session[:current_user_id] &&
User.find_by_id(session[:current_user_id])
end
end
如何理解上面的代码?是什么||=
意思?是@_current_user
id 还是 user 对象?另外,为什么它以 开头_
?
谁能回答我@_current_user
是什么?