I am using Devise for Rails. In the default registration process, Devise requires users to type the password twice for validation and authentication. How can I disable it?>
Devise's default validations (lib/devise/models/validatable.rb):
validates_confirmation_of :password, :if => :password_required?
and method:
def password_required?
!persisted? || !password.nil? || !password_confirmation.nil?
end
We need override Devise default password validation. Put the following code at the end in order for it not to be overridden by any of Devise's own settings.
validates_confirmation_of :password, if: :revalid
def revalid
false
end
And your model would look like this:
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable,
:confirmable, :timeoutable, :validatable
validates_confirmation_of :password, if: :revalid
def revalid
false
end
end
Then remove the password_confirmation field from the registration form.