title: Devise: update (edit) User via Ajax
body: <p>I already successfully made sign-in/sign-up to work via Ajax in Devise (following an article in blog post). But I can't make it to work with ajax <strong>update</strong> action. I want a user to be able to edit his settings via ajax, receiving proper JSON response.</p>
  
  <p>So tried to copy <strong>update</strong> method from Devise and I edited it to send back proper JSON response:</p>
  
  <pre><code>class RegistrationsController &lt; Devise::RegistrationsController
    def update
      self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
      prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
  
      if update_resource(resource, account_update_params) # &lt;&lt;&lt; PROBLEM IS HERE
        sign_in resource_name, self.resource, :bypass =&gt; true
        render json: resource, status: :ok
      else
        clean_up_passwords resource
        render json: resource, status: :not_acceptable
      end
    end
  end
  </code></pre>
  
  <p>This gives me an error: </p>
  
  <pre><code>undefined local variable or method "account_update_params"
  </code></pre>
  
  <p><strong>account_update_params</strong> is a protected method in one of Devise's files - if I copy+paste it to my child class:</p>
  
  <pre><code>  def account_update_params
      devise_parameter_sanitizer.sanitize(:account_update)
    end
  </code></pre>
  
  <p>it gives me next error </p>
  
  <pre><code>devise_parameter_sanitizer not found
  </code></pre>
  
  <p>So it looks like I'm going a wrong way.</p>