Rails 3 with Devise: no route matches / d / users / sign_out

I get the following error when I try to exit a development error:

No route match [GET] "/ d / users / sign_out"

My tag is correct, it looks like this:

<%= link_to "Sign Out", destroy_session_path, :method=>:delete %> 

My development route:

 devise_for :users, :path_prefix=>"d", :controllers=>{:sessions=>"sessions"} 

Other routes:

 resources :users#For CRUD defined after devise_for like in Devise Wiki 

Using custom controller sessions to log in to ajax, for example, 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 development initializer has:

 config.sign_out_via = :delete 

Any ideas on what might cause the problem? I searched Google and is still at a dead end.

Update:

Here is a screenshot of the rails routes file for developers. Sorry, it's small, but you can right-click and then view it separately for a larger screen.

enter image description here

Update # 2:

The jquery_ujs file is included.

Update No. 3:

The console shows that the deletion is actually being transmitted, but it jumps from session_controller to / then to d / users / sign_out ... You don’t know how to fix it.

Update # 4:

When redirecting, it first goes to d / users / sign_out as DELETE, as it should. It then redirects to root_url , which then throws an error ERROR Errno::ECONNABORTED: An established connection was aborted by the software in your host machine. Then it tries to redirect d / users / sign_out as GET, where it does not work.

+6
source share
3 answers

This is apparently the problem between Devise and Ruby 1.9.2-p290. Upgrading to Ruby 1.9.3 and running bundle update to ensure you use the latest version of Devise; seems to work.

+5
source

It looks like you removed //= require jquery_ujs from your application.js file. I think it processes the link data to make a delete request. In any case, as now, you are creating a "GET" that, obviously, will not hit your destroy_user_session method.

+1
source

Edit:

 config.sign_out_via = :delete 

in

 config.sign_out_via = :get 

See the following:

No matching routes "/ users / sign_out" reinvent the rails 3

+1
source

Source: https://habr.com/ru/post/920439/


All Articles