0
votes

I have a Rails 3 app and I want to show 4 main fields:

1. current password

2. current password confirm

3. new password

4. new password confirm

as well as a bunch of other fields for the user, and I only want to require the user to enter their current password if they enter a new password.

However, I cannot find how to do this in Devise.

What are the attributes of Devise to let me do this?

1

1 Answers

0
votes

if you add

devise :validatable

to your user model, Devise will automatically validate your model. The validation logic can be found at: https://github.com/plataformatec/devise/blob/master/lib/devise/models/validatable.rb#L53

you could also overwrite this method in your controller by simply overwriding the Devise method like so:

  def password_required?
    prepared? || !password.nil? || !password_confirmation.nil?
  end