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