Devise Registration#update via JS in Rails

I'm trying to update the User model through Devise with AJAX and have Devise respond with the proper javascript file.

I want to submit the form remotely to the registrations#update action, but this isn't working with the default response from Devise, which uses the following from the RegistrationsController:

respond_with resource, :location => after_update_path_for(resource)

The above tries to redirect to the default route instead of rendering the update.js.erb file. I am able to overwrite the action and have it work with the following change:

respond_to do |format|

But, this seems very brute force as I'm overriding the entire action. Is there a simple way for Devise to know to respond with javascript instead of doing its default redirect?


Simply had to add a line to the RegistrationsController so that Devise knows to respond_to both html and js.

class RegistrationsController < Devise::RegistrationsController
  respond_to :html, :js

Reading up on how respond_with really helped. Couple of good links:

Rails API Responder


Need Your Help

RESTful Java application connecting to PHP

java php rest tomcat

I am starting a web project in which I would like to have a RESTful Java back-end and a PHP front-end that consumes it (its my first time using REST, although I have a lot of experience with Java and

What are the good implementation practices to minimize RAM consumption

c performance memory-management ram memory-efficient

I run a C code on an arm based Linux device that has a very small RAM space (16MB). My code is often killed (SIGKILL) by the kernel with 'out of memory' message. I run the program with Valgrind, an...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.