defcurrent_user@current_user||=beginlogin_from_session||login_from_cookieend# @current_user ||= begin# User.current = (login_from_session || login_from_cookie) # endend# Store the given user id in the session.defcurrent_user=(new_user)session[:user_id]=new_user?new_user.id:nil@current_user=new_user||nilenddeflogin_from_sessionself.current_user=User.where(:_id=>session[:user_id]).firstifsession[:user_id]enddeflogin_from_cookienilend