在密码重置过程中,为Devise模型中的某些成员跳过验证 [英] Skip validation for some members in Devise model during password reset

查看:101
本文介绍了在密码重置过程中,为Devise模型中的某些成员跳过验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的用户(Devise)模型也有名字,城市,国家,电话成员。

My User (Devise) model also has name, city, nation, phone members.

在创建注册页面 - 我 validates_presence_of city ,国家,电话,姓名,电子邮件,:on =>:创建

In the create registration page - I validates_presence_of city, nation, phone, name, email, :on => :create

在编辑注册页面 - 我 validates_presence_of city,nation,phone,name,on =>:update

In the edit registration page - I validates_presence_of city, nation, phone, name, :on => :update

现在,当我在forgot_password_page上设置一个新密码时,城市,国家,电话,名称在内的存在Devise :: PasswordsController#update

Now when I set a new password on forgot_password_page, it asks for the presence of city, nation, phone, name inside Devise::PasswordsController#update

我如何处理选择验证?

我猜这应该是这样的,

validates_presence_of city, nation, phone, name, :on => :update, :if => :not_recovering_password

def not_recovering_password
  # what goes here
end


推荐答案

得到José的答案 - https:/ /github.com/plataformatec/devise/issues/1623

Got an answer from José - https://github.com/plataformatec/devise/issues/1623

这篇关于在密码重置过程中,为Devise模型中的某些成员跳过验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆