I am getting the following error when I try to sign out of devise error:
No route matches [GET] "/d/users/sign_out"
My tag is correct, it is as follows:
<%= link_to "Sign Out", destroy_session_path, :method=>:delete %>
My route for devise is:
devise_for :users, :path_prefix=>"d", :controllers=>{:sessions=>"sessions"}
Other routes are:
resources :users#For CRUD defined after devise_for like in Devise Wiki
With a custom controller sessions for ajax login like on the Devise wiki page:
class SessionsController < Devise::SessionsController
 def create
  respond_to do |format|
    format.html{ super }
    format.json do
     resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure")
     #resource = warden.authenticate!(:scope => resource_name, :recall => :failure)
     return sign_in_and_redirect(resource_name, resource)
    end
   end
  end
def sign_in_and_redirect(resource_or_scope, resource=nil)
  scope = Devise::Mapping.find_scope!(resource_or_scope)
  resource ||= resource_or_scope
  sign_in(scope, resource) unless warden.user(scope) == resource
  return render :json => {:success => true, :redirect => stored_location_for(scope) || after_sign_in_path_for(resource)}
end
def failure
  return render:json => {:success => false, :errors => ["Login failed."]}
end
end
The devise initializer has:
config.sign_out_via = :delete
Any ideas on what could be causing the problem? I've searched Google and am still stumped.
Here is a screenshot of the rails routes file for the devise users. Sorry, it is small, but you can right-click then view it by itself for a larger screen.

The jquery_ujs file is included.
It appears in the console that delete is indeed being passed, but it is jumping from the sessions_controller to / then to d/users/sign_out...Not sure how to fix this.
When redirecting it goes first to d/users/sign_out as DELETE, as it should.  It then redirects to root_url which then gives the error ERROR Errno::ECONNABORTED: An established connection was aborted by the software in your host machine.  It then tries to redirect to d/users/sign_out as GET where it is failing.
This appears to be an issue between Devise and Ruby 1.9.2-p290. Updating to Ruby 1.9.3 and running bundle update  to ensure the latest version of Devise was used; appears to work.
It sounds like you might have removed //= require jquery_ujs from your application.js file.  I think that handles the link particulars to make a 'delete' request.  Either way, as it is now, you're making a 'GET' which obviously won't hit your destroy_user_session method.
Change:
config.sign_out_via = :delete
to:
config.sign_out_via = :get
See this related:
No route matches "/users/sign_out" devise rails 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With