title: Ruby on Rails, Devise gem. How to remove current password when password is blank?
body: <p>Now I realise this topic has been covered many times before. However there did not appear to be a solution that wanted to make the current password field exempt only when the password in the database was blank.</p>
  
  <p>I currently have the password required in my user model like:</p>
  
  <pre><code>def password_required?
    (authentications.empty? || !password.blank?) &amp;&amp; super
  end
  </code></pre>
  
  <p>Then I copied the update function across into my registrations controller:</p>
  
  <pre><code>def update
    if resource.update_with_password(params[resource_name])
      set_flash_message :notice, :updated
      sign_in resource_name, resource, :bypass =&gt; true
      redirect_to after_update_path_for(resource)
    else
      clean_up_passwords(resource)
      render_with_scope :edit
    end
  end
  </code></pre>
  
  <p>I just don't know how to go about ensuring that devise does not need a password when editing a blank password, do I also need to remove the current_password field from the view and do this?</p>
  
  <pre><code>&lt;% if current_user.password_required? %&gt;
    &lt;p&gt;&lt;%= f.label :current_password %&gt; &lt;i&gt;(we need your current password to confirm your changes)&lt;/i&gt;&lt;br /&gt;
    &lt;%= f.password_field :current_password %&gt;&lt;/p&gt;
  &lt;% end %&gt;
  &lt;p&gt;&lt;%= f.submit "Update" %&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Any suggestions would be great on this as I am sure I am overlooking something but I am still new to Rails on a whole. Thanks!</p>