I created a controller called SessionController
class Users::SessionsController < Devise::SessionsController append_view_path 'app/views/devise' def create respond_to do |format| format.html { super } format.json { warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new") current_user.ensure_authentication_token! render :json => {:user => current_user.api_attributes, :auth_token => current_user.authentication_token}.to_json, :status => :ok } end end def destroy respond_to do |format| format.html { super } format.json { warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new") current_user.empty_authentication_token! render :json => {}.to_json, :status => :ok } end end end
And added this to the root file:
devise_for :users, :controllers => { :sessions => "users/sessions" }
And it works :-)
source share