I have the following helper methods in the application_controller.rb for authlogic:
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.record
end
I do not understand how the current_user_session method - specifically, how UserSession.find obtains the current user's session. I also do not understand what it is doing with find, where no argument is given.
It doesn't need to pass it an argument since it uses a unique session ID whose functionality is built into Rails . Check out the authlogic documentation for the find method for more information on it. It's not the same thing as an Active Record class, where find
queries the database for a specific primary key.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.