1
好的,我做了一個登錄操作,但我對如何設置功能或單元測試有點困惑。會不會像從我的燈具發送用戶名和密碼,並檢查會話[:user_id]是否爲零?如何在Rails中爲此設置功能測試?
感謝提前:)
#POST /sessions
def create
user = User.authenticate(params[:email],params[:password])
if user
session[:user_id] = user.id
redirect_to root_path, :notice => "Logged in successfully!"
else
flash.now.alert = "Invalid username/password"
render "new"
end
end