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

后端 未结 1 2074
长发绾君心
长发绾君心 2021-02-09 09:43

In my Rails app, Admins are the people who add users to the system. 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 u

1条回答
  •  走了就别回头了
    2021-02-09 10:37

    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
    

    0 讨论(0)
提交回复
热议问题