Skip email validation for omniauth-twitter on devise 2.0

后端 未结 4 1268
Happy的楠姐
Happy的楠姐 2020-12-08 22:01

I\'m using devise 2.0 and gem omniauth-twitter

The problem is that twitter does not send an email in response, so the model user of my application validates that the

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 22:49

    Add this to your User model:

    def email_required?
      super && provider.blank?
    end
    

    You can use an equivalent method for the password:

    def password_required?
      super && provider.blank?
    end
    

    This should override the field requirements when using Omniauth providers.

提交回复
热议问题