title: Still getting "Current password can't be blank" in Registration Edit after following wiki
body: <p>I worry the solution here will be woefully obvious, but I'm having trouble implementing the instructions on the Devise wiki (<a href="https://github.com/plataformatec/devise/wiki/How-To%3a-Allow-users-to-edit-their-account-without-providing-a-password" rel="noreferrer">https://github.com/plataformatec/devise/wiki/How-To%3a-Allow-users-to-edit-their-account-without-providing-a-password</a>)</p>
  
  <p>I'm using Rails 4. After following the wiki, I'm still receiving "current password can't be blank". Here's my setup. Any assistance is much appreciated!</p>
  
  <p><strong>REGISTRATIONS_CONTOLLER.rb</strong></p>
  
  <pre><code>class RegistrationsController &lt; Devise::RegistrationsController
    def update
      @user = User.find(current_user.id)
  
      successfully_updated = if needs_password?(@user, params)
        @user.update_with_password(devise_parameter_sanitizer.for(:account_update))
        # Rails 3:  @user.update_with_password(params[:user])
      else
        # remove the virtual current_password attribute update_without_password
        # doesn't know how to ignore it
        params[:user].delete(:current_password)
        @user.update_with_password(devise_parameter_sanitizer.for(:account_update))
        # Rails 3: @user.update_without_password(params[:user])
      end
  
      if successfully_updated
        set_flash_message :notice, :updated
        # Sign in the user bypassing validation in case his password changed
        sign_in @user, :bypass =&gt; true
        redirect_to after_update_path_for(@user)
      else
        render "edit"
      end
    end
  
    private
    # check if we need password to update user data
    # ie if password or email was changed
    # extend this as needed
    def needs_password?(user, params)
      user.email != params[:user][:email] ||
        params[:user][:password].present?
    end
  end
  </code></pre>
  
  <p><strong>APPLICATION_CONTROLER.rb</strong></p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    protect_from_forgery with: :exception
  
    before_filter :configure_permitted_parameters, if: :devise_controller?
  
    def configure_permitted_parameters
      devise_parameter_sanitizer.for(:account_update) do |u|
        u.permit(:first_name, :last_name, :username, :email, :avatar, :password, :password_confirmation)
      end
      devise_parameter_sanitizer.for(:sign_up) do |u|
        u.permit(:first_name, :last_name, :username, :email, :password, :password_confirmation)
      end
      devise_parameter_sanitizer.for(:sign_in) do |u|
        u.permit(:username, :email, :password)
      end
    end
  end
  </code></pre>
  
  <p><strong>ROUTES.rb</strong></p>
  
  <pre><code>ProjectFoo::Application.routes.draw do
    devise_for :users, :controllers =&gt; { :registrations =&gt; "registrations",
                                         :invitations =&gt; 'users/invitations' }
  </code></pre>
  
  <p>Note: I'm also using the devise_invitable gem</p>
  
  <p><strong>VIEWS/DEVISE/REGISTRATIONS/EDIT.html.erb</strong></p>
  
  <pre><code>&lt;h2&gt;Edit &lt;%= resource_name.to_s.humanize %&gt;&lt;/h2&gt;
  &lt;%= image_tag @user.avatar.url(:square) %&gt;
  
  &lt;%= form_for(resource, :as =&gt; resource_name, :url =&gt; registration_path(resource_name), :html =&gt; { :method =&gt; :put, :class =&gt; 'form-horizontal' }) do |f| %&gt;
    &lt;%= devise_error_messages! %&gt;
  
    &lt;div class="span5"&gt;
      &lt;div class="control-group"&gt;
        &lt;%= f.label :email, :class =&gt; 'control-label' %&gt;
          &lt;div class="controls"&gt;
            &lt;%= f.email_field :email, :autofocus =&gt; true, :class =&gt; 'text_field' %&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="control-group"&gt;
      &lt;%= f.label :username, :class =&gt; 'control-label' %&gt;
        &lt;div class="controls"&gt;
         &lt;%= f.text_field :username, :autofocus =&gt; true, :class =&gt; 'text_field' %&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="control-group"&gt;
        &lt;%= f.label :first_name, :class =&gt; 'control-label' %&gt;
          &lt;div class="controls"&gt;
            &lt;%= f.text_field :first_name, :autofocus =&gt; true, :class =&gt; 'text_field' %&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="control-group"&gt;
        &lt;%= f.label :last_name, :class =&gt; 'control-label' %&gt;
          &lt;div class="controls"&gt;
            &lt;%= f.text_field :last_name, :autofocus =&gt; true, :class =&gt; 'text_field' %&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="control-group"&gt;
        &lt;%= f.label :twitter_handle, :class =&gt; 'control-label' %&gt;
        &lt;div class="controls"&gt;
          &lt;%= f.text_field :twitter_handle, :autofocus =&gt; true, :class =&gt; 'text_field' %&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="control-group"&gt;
        &lt;%= f.label :avatar, :class =&gt; 'control-label' %&gt;
          &lt;div class="controls"&gt;
            &lt;%= f.file_field :avatar, :class =&gt; 'file_field' %&gt;
          &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
    &lt;div class="span5"&gt;
      &lt;% if devise_mapping.confirmable? &amp;&amp; resource.pending_reconfirmation? %&gt;
        &lt;div&gt;Currently waiting confirmation for: &lt;%= resource.unconfirmed_email %&gt;&lt;/div&gt;
      &lt;% end %&gt;
  
      &lt;div class="control-group"&gt;
        &lt;%= f.label :password, :class =&gt; 'control-label' %&gt;
          &lt;div class="controls"&gt;
            &lt;%= f.password_field :password, :autocomplete =&gt; "off", :class =&gt; 'password_field' %&gt;&lt;br&gt;&lt;i&gt;(leave blank if you don't want to change it)&lt;/i&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="control-group"&gt;
        &lt;%= f.label :password_confirmation, :class =&gt; 'control-label'  %&gt;
          &lt;div class="controls"&gt;
            &lt;%= f.password_field :password_confirmation, :class =&gt; 'password_field' %&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="control-group"&gt;
        &lt;%= f.label :current_password, :class =&gt; 'control-label'  %&gt;
          &lt;div class="controls"&gt;
           &lt;%= f.password_field :current_password, :class =&gt; 'password_field' %&gt;&lt;p&gt;&lt;i&gt;(we need your current password to confirm your changes)&lt;/i&gt;&lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;%= f.submit "Update" %&gt;
  
    &lt;/div&gt;
  &lt;% end %&gt;
  
  &lt;div class="span11"&gt;
    &lt;hr&gt;
  &lt;/div&gt;
  
  &lt;div class="span11"&gt;
    &lt;h3&gt;Cancel my account&lt;/h3&gt;
  
    &lt;p&gt;Unhappy? &lt;%= button_to "Cancel my account", registration_path(resource_name), :data =&gt; { :confirm =&gt; "Are you sure?" }, :method =&gt; :delete %&gt;&lt;/p&gt;
  
    &lt;p&gt;&lt;%= link_to "Back", :back %&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>