0
votes

in my Rails app have this routes.rb:

 devise_for :admin
 namespace :admin do
     root :to  => 'dashboard#index'
     resources :customers 
 end

If try to logout with link_to('Logout',destroy_admin_session_path, :method => :delete), but rails print "No route matches [GET] "/admin/sign_out""

Is possible to fix without changes routes?

4

4 Answers

1
votes

It looks like the :method option doesn't work since you ask a DELETE and have a GET. Make sure you have <%= javascript_include_tag :defaults %> in your layout

You may also read this question about the same problem : No route matches "/users/sign_out" devise rails 3

1
votes

Have resolved by setting GET method for sign_out action, not so secure but works. If anyone has the same problem this is the new routes.rb:

devise_for :admin, :sign_out_via => [ :get ]
 namespace :admin do
     root :to  => 'dashboard#index'
     resources :customers 
 end

If anyone have more secure fix is welcome

0
votes

i know this is an old post but i had the same problem (not using devise but a custom solution)

and for me it was that in my application layout(named admin.html.erb because i had an admin namespace like you) i had to include the following line for it to work with delete and not get.

<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>

what matters is the first part , i dont think turbolinks help this error at all.

0
votes

Check if this code is in head section in application.html.erb file, add if it's not. Works for me.

<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>