0

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?

byterussian
  • 3,271
  • 5
  • 26
  • 35

4 Answers4

1

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

Community
  • 1
  • 1
tight
  • 753
  • 5
  • 11
1

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

byterussian
  • 3,271
  • 5
  • 26
  • 35
0

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.

Petros Kyriakou
  • 4,660
  • 4
  • 35
  • 70
0

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' %>
ForvaN
  • 1