我对第8章,练习2:
感到困惑Use session instead of cookies so that users are automatically signed out when they close
their browsers.
在这里和github进行讨论,看来完成此任务的方法是修改SessionsController,如下所示:
def create
user = User.find_by_email(params[:session][:email])
if user && user.authenticate(params[:session][:password])
...
但是当我这样做时,我再也无法登录了:
NoMethodError in SessionsController#create
undefined method `[]' for nil:NilClass
我需要修改哪些内容才能使用session而不是Cookie进行身份验证?
答案 0 :(得分:-1)
线索出现在错误NoMethodError in SessionsController#create
#there表示SessionsController中的create方法。