def create
user = User.find_by_name(params[:name])
if user and user.authenticate(params[:password])
session[:user_id] = user.id
redirect_to admin_url
else
redirect_to login_url, alert: "Invalid user/password combination"
end
end
这里为什么用户被声明为局部变量而不是实例变量@user?为什么我们不在认证中使用@var?