[英]In Rails when using the Devise gem how to create a user without email and password?
In my Rails app, Admins are the people who add users to the system. 在我的Rails应用程序中,管理员是将用户添加到系统的人员。 If the user doesn't have an email, a password won't be generated for him and he can't log in. But if the user have an email, a password will be generated.
如果用户没有电子邮件,则不会为他生成密码,也无法登录。但如果用户有电子邮件,则会生成密码。 But the problem is, devise won't allow blank passwords.
但问题是,设计不允许空白密码。 How can we fix this?
我们该如何解决这个问题?
you can override them in your user model: 您可以在用户模型中覆盖它们:
def password_required?
false
end
def email_required?
true
end
Edit: 编辑:
def password_required?
new_record? ? false : super
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.