[英]NoMethodError in SessionsController#create
Ok, I'm learning R on R from the Pragmatic Bookshelf text Agile Webdevelopment with Rails 4th ed. 好的,我正在从带Rails第四版的实用书架文本Agile Webdevelopment中学习R onR。
I'm at page 212 and I'm getting this error.... NoMethodError in SessionsController#create
and app/controllers/sessions_controller.rb:7:in 'create'
我在第212页,但出现此错误。...
NoMethodError in SessionsController#create
和app/controllers/sessions_controller.rb:7:in 'create'
NoMethodError in SessionsController#create
I'm pulling my beard out over here, I've spent days trying to track this down. 我要把胡须拉到这里,我花了几天的时间试图找出答案。 Here is the create code this is pointing to...
这是它指向的创建代码...
def create
if user = User.authenticate(params[:name], params[:password])
session[:user_id] = user.id
redirect_to admin_url
else
redirect_to login_url, :alert => "Invalid user/password combination"
end
end
Can any Guru out there assist? 那里的任何一位上师可以协助吗?
Sounds like you need the following in your user model (page 203 on my book.) If that is not the issue, please provide your user model too. 听起来您的用户模型中需要以下内容(我的书的第203页。)如果这不是问题,请也提供您的用户模型。
def User.authenticate(name, password)
if user = find_by_name(name)
if user.hashed_password == encrypt_password(password, user.salt)
user
end
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.