Ruby on rails 验证时出错
我的Ruby on Rails代码中有一个问题:Ruby on rails 验证时出错,ruby-on-rails,Ruby On Rails,我的Ruby on Rails代码中有一个问题: class SessionsController < ApplicationController def new @title = "Sign in" end def destroy end def create user = User.authenticate(params[:session][:email], params[:session][:password])
class SessionsController < ApplicationController
def new
@title = "Sign in"
end
def destroy
end
def create
user = User.authenticate(params[:session][:email],
params[:session][:password])
if user.nil?
flash.now[:error] = "Invalid email/password combination."
@title = "Sign in"
render 'new'
else
sign_in user
redirect_to user
end
end
def destroy
sign_out
redirect_to root_path
end
end
class sessioncontroller
错误消息:
private method `has_password?' called for #<User:0xb729d558>
app/models/user.rb:72:in `authenticate'
app/controllers/sessions_controller.rb:8:in `create'
private方法'has_password'已被调用#
app/models/user.rb:72:in'authenticate'
app/controllers/sessions\u controller.rb:8:in'create'
我该如何解决这个问题?对于用户身份验证,我建议您使用gems。下面是我在开发中更喜欢的gems。朋友,我认为这会有所帮助 也访问