0

I use clearance in app. When user try sign out, have routing error:

 Failure/Error: visit sign_out_path

 ActionController::RoutingError:
   No route matches [GET] "/sign_out"

Sign out link in view:

  = link_to t(".sign_out"), sign_out_path, method: :delete

In roures.rb configuration

get "/sign_in",      to: "clearance/sessions#new", as: "sign_in"
get "/session",      to: "clearance/sessions#new", as: "session"
delete "/sign_out",  to: "clearance/sessions#destroy", as: "sign_out"
get "/sign_up",      to: "clearance/users#new", as: "sign_up"

resources :passwords, controller: "clearance/passwords", only: [:create, :new]
resources :session, controller: "clearance/sessions", only: [:create]

resources :users, controller: "users", only: [:create] do
  resources :password,
    controller: "clearance/passwords",
    only: [:create, :edit, :update]
end

root  to: "welcome#welcome_page"

resources :welcome, only: [:welcome_page],  path:''
resources :pages, only: [:show]
resources :users

mount RailsAdmin::Engine => '/admin', as: 'rails_admin'

Rails 5 + Ruby 2.2.2

alexin
  • 243
  • 1
  • 15
  • You only have a route for delete and are trying to use get? – Sami Kuhmonen Nov 04 '16 at 21:41
  • I try fix error, and add `get "/sign_out", to: "clearance/sessions#destroy", as: "sign_out"` in routes. But it wrong.I forgot to remove the string when written question. – alexin Nov 04 '16 at 21:44

1 Answers1

1

To solve this you have 2 options.

Either ensure you have jquery_ujs in application.js

//= require jquery
//= require jquery_ujs

Or, if you don't want to use jquery change your link to a button:

= button_to t(".sign_out"), sign_out_path, method: :delete

This is summarised from the following SO Question : Rails Link To Method Getting When It Should Delete

Community
  • 1
  • 1
David
  • 3,510
  • 3
  • 21
  • 39
  • Thenks for help. I found mistake. The mistake was in the path javascript_include_tag in my application layout. – alexin Nov 05 '16 at 17:47