devise: not requiring email

前端 未结 4 1462
你的背包
你的背包 2021-01-01 15:31

I would like to NOT require email for signing in using devise. I removed email from config/initializers/devise.rb:

config.authentication_keys = [ :login ]
         


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-01-01 16:03

    In my case, I removed the column email from my users in the database, and Devise started to crash. I added this:

    # app/models/user.rb
    def email_required?
      false
    end
    
    def email_changed?
      false
    end
    

    and it worked properly.

    Please note that removing :validatable would remove password validations. So some references say you shoudn't remove it.


    Tip: Add a simple comment above those lines explaining your motives. Those after you will be thankful

提交回复
热议问题