Devise logs me out on Ajax calls using PostgreSQL #913

kurko opened this Issue Mar 13, 2011 · 3 comments

3 participants


This is really weird. I started using SQLite in this project. Devise was working fine.

Then I switched to MySQL. No problem. Now I am trying PostgreSQL and a weird bug popped up: I can login normally, but whenever I make an Ajax call, I get a 401 Unauthorized response.

I just switched to PostgreSQL. PSQL is working fine because I can login, insert new rows, but at the moment I make a Ajax call, it logs me out. Any Ajax call, be it in whatever page. Addicionally, I know PostgreSQL requires some special treatment on queries, but it's all working fine.

I am a bit of a noob in Ruby, but I looked at Devise tests and haven't found any test specific for PostgreSQL.

So, could anyone test this?

Plataformatec member

In theory, there is no need to test. ActiveRecord should be responsible to abstract those differences between databases and Devise is not doing anything special related to it. Try pasting your log in the ajax request, Rails and Devise versions. It may help identify the problem. Also, try the mailing list, others may have had the same issue.


You need to make sure you are sending the csrf token with your request, otherwise rails resets the session.

Are you using jQuery? Make sure you have the latest rails.js. It automatically sends the csrf token with each request.

More info:


Unbelievable, it worked.

I'd never imagina it was caused by the csrf token because I was working with SQLite and MySQL for the past 30 days, not having any problem at all. The moment I started using psql, I got this weird problem.

Thanks José, thanks stevehodgkiss.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment