[英]NoMethodError in SessionsController#create
class SessionsController < ApplicationController
def new
@title = "Sign in"
end
def create
user = User.authenticate(params[:session][:email],
params[:session][:password])
if user.nil?
flash[:error] = "Invalid email/password combination."
@title = "Sign in"
render 'new'
else
# Sign the user in and redirect to the user's show page.
end
end
def destroy
end
end
Currently working on a project and have got an a undefined NoMethodErorr. 当前正在从事一个项目,并且有一个未定义的NoMethodErorr。 Done thorough research and still unable to find anything.
经过彻底的研究,仍然找不到任何东西。 What I have done is that inside the create actions the params takes the paramaeters needed to authenticate.
我所做的是,在创建动作中,参数接受了进行身份验证所需的参数。 I created the following method User.authenticatte.
我创建了以下方法User.authenticatte。 However when I run this in my localhost I get the following error.
但是,当我在本地主机上运行此命令时,出现以下错误。 What could possibly be the problem?
可能是什么问题?
NoMethodError in SessionsController#create
undefined method `authenticate' for #<Class:0x4589eb0>
The controller is looking for an Authenticate method for the User model. 控制器正在寻找User模型的Authenticate方法。 This method is not present.
此方法不存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.