在密码重置期间跳过对设计模型中某些成员的验证 [英] Skip validation for some members in Devise model during password reset
问题描述
我的用户(设计)模型也有姓名、城市、国家、电话成员.
My User (Devise) model also has name, city, nation, phone members.
在创建注册页面 - 我 validates_presence_of 城市、国家、电话、姓名、电子邮件,:on => :create
In the create registration page - I validates_presence_of city, nation, phone, name, email, :on => :create
在编辑注册页面 - I validates_presence_of city, national, 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
这篇关于在密码重置期间跳过对设计模型中某些成员的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!