rails中validates_confirmation_of验证方法无效的解决办法

简介:

    rails的model中提供了很多种自带的验证方法,validates_confirmation_of可以验证变量xxx和xxx_confirmation是否相等;这可以用于验证2遍输入的密码是否一致的情况。但是实际使用中发现上述验证方法貌似没有进行验证;在确认了变量:password和:password_confirmation名称确实没错的情况下,研究了半天,发现还要做一步操作,就是要在controller的user_params的许可中加入:password_confirmation才可以哦:

# Never trust parameters from the scary internet, only allow the white list through.
    def user_params
      params.require(:user).permit(:name, :password, :password_confirmation,\
        :depart, :email, :is_admin, :remark)
    end


相关文章
|
7月前
|
存储
mPaaS一直报Config License验证失败的错误
mPaaS一直报Config License验证失败的错误
233 2
|
7月前
|
Java 数据库
错误解决方案
错误解决方案
113 0
|
2月前
|
定位技术 UED
[亲测]解决ChatGPT邮箱注册失败,提示The email you provided is not supported
[亲测]解决ChatGPT邮箱注册失败,提示The email you provided is not supported
310 0
Mac Source Tree拉代码报错,remote: CODING 提示: Authentication failed. remote: 认证失败,请确认您输入了正确的账号密码。 fatal...
Mac Source Tree拉代码报错,remote: CODING 提示: Authentication failed. remote: 认证失败,请确认您输入了正确的账号密码。 fatal...
1457 0
Mac Source Tree拉代码报错,remote: CODING 提示: Authentication failed. remote: 认证失败,请确认您输入了正确的账号密码。 fatal...
|
2月前
|
Web App开发 移动开发 开发者
mPaaS问题之提示License验证失败如何解决
mPaaS配置是指在mPaaS平台上对移动应用进行的各项设置,以支持应用的定制化和优化运行;本合集将提供mPaaS配置的操作指南和最佳实践,助力开发者高效管理和调整移动应用的设置。
45 1
|
6月前
|
数据库
Gitlab其他用户登录返回500错误解决
Gitlab其他用户登录返回500错误解决
116 0
|
Linux
解决Kubuntu下登录vscode时报错:将登录信息写入密钥链失败,出现错误 “GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown
解决Kubuntu下登录vscode时报错:将登录信息写入密钥链失败,出现错误 “GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown
622 0
|
SQL 关系型数据库 MySQL
The user specified as a definer (‘root‘@‘%‘) does not exist【亲测可用,服务器端】
The user specified as a definer (‘root‘@‘%‘) does not exist【亲测可用,服务器端】
51 0
The user specified as a definer (‘root‘@‘%‘) does not exist【亲测可用,服务器端】