Jared
Jared

Reputation: 2457

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

So far as I can tell, in order 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

Upvotes: 2

Views: 907

Answers (1)

Mark Fraser
Mark Fraser

Reputation: 3198

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

Upvotes: 1

Related Questions