Mohsin Shafique
Mohsin Shafique

Reputation: 935

Devise asks authentication for Ajax request

I am working on a Rails 3 app which has devise as authentication. What I am trying to accomplish is pretty simple. I am updating an object on click of an attribute so here is my AJAX call:

$.post('/users/' + userId + '.json', user, function(data, textStatus, jqXHR){});

And in response to above call, I get an HTTP authentication dialog from the browser. I am wondering what might be the case? Any ideas what's going on here?

Upvotes: 0

Views: 802

Answers (1)

Braden Becker
Braden Becker

Reputation: 2499

By default Devise requires you to provide a password whenever you try to update a user so based on your description I am assuming this is the cause of your problem. There is a devise wiki page that tells you how to change this behavior. Another option would be to write your own controller to handle updates to your user model outside of devise. If you do disable the password requirement I would encourage you to enable some level of authorization to prevent everyone from being able to update user models. CanCan is a simple and easy authorization gem that could help.

Upvotes: 2

Related Questions