写了个登录功能:(输入手机号和密码实现登录功能)
登录方法如下:
def login_session
customer = Customer.where(cus_phone: params[:cus_phone])
if customer && customer.authenticate(params[:cus_password])
session[:cus_id] = customer.id
params[:session][:remember_me] == '1' ? remember(customer) : forget(customer)
redirect_to customers_path
else
render :sign_in
end
end
gemfile 里边儿已经加了:bcrypt-ruby 这个 gem
model 里边儿也 include 了 SecurePassword 指明一点我用的是 mongoid 没用 ActiveRecord
include ActiveModel::SecurePassword
has_secure_password
但是现在的问题一直在报 undefined method `authenticate' 求大神指点