Search code examples
ruby-on-rails-3sessiondevisewardensession-storage

Prevent session creation on rails 3.2.2 for RESTful api


How can i prevent the session store from creating a session on JSON/XML calls ?

My problem is that i save sessions in a database and it gets flooded on multiple api calls.

I'm using Rails 3.2.2 and Devise for authentication.


Solution

  • My problem here was with Warden inside Devise. I had to "tell" Warden not to store the user in the session after the user is authenticated.

    resource = warden.authenticate!(:scope => resource_name, :store => !(request.format.xml? || request.format.json?))
    

    Hope that helps whoever sees this thread.