开发者

Devise's validateable module doesn't respect custom defined email_required? method

So far as I can tell, in ord开发者_运维百科er to use the validateable module, but selectively disable the email field's validations, you must define a protected method email_required? on your model and have it return false.

I've done this, but it appears the email validation is still triggered. Is this a bug in devise, or am I missing a crucial step?

Below are the relevant parts of my User model:

class User < ActiveRecord::Base
    devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable

    protected
      def email_required?
        false 
      end
end


In case anyone is still running into this, it has been added--but I believe only in the 1.2 branch. Download and install the 1.2rc and you can skip email validation as done in the question.

https://github.com/plataformatec/devise

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜