In Rails when using Devise gem how to create a user without email and password?

In my Rails application, admins are people who add users to the system. If the user does not have an email, a password will not be created for him, and he will not be able to log in. But if the user has an email, a password will be created. But the problem is that devise will not allow empty passwords. How can we fix this?

+6
source share
1 answer

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 
+14
source

Source: https://habr.com/ru/post/969835/


All Articles