app/helpers/sessions_helper.rb代码如下:
module SessionsHelper
def sign_in(user)
cookies[:remember_token]= user.remember_token
self.current_user=user
end
def signed_in?
!current_user.nil?
#!!current_user
end
def current_user=(user)
@current_user = user
end
def current_user
@current_user ||= User.find_by_remember_token(cookies[:remember_token])
#@current_user
end
def sign_out
self.current_user=nil
cookies.delete(:remember_token)
@current_user = nil
end
def current_user?(user)
user == current_user
end
end
不知道为什么其中的 signed_in?方法总是返回 true