'No route matches [DELETE] "/users/sign_out" on Rails 6

I just found out about this issue today as I'm reviewing all my projects and all the other posts I found either seem to be about earlier versions of Rails or have solutions I looked into.

I'm trying to sign out my users and I get this error No route matches [DELETE] "/users/sign_out".

Here's my link,

<%= link_to "Sign Out", destroy_user_session_path, method: :delete, :class => 'navbar-link'  %>

My Routes, I'm also using omniauth to sign in with third parties.

devise_for :users, :controllers => { :omniauth_callbacks => "callbacks" }

And here's what I have in devise.rb

config.sign_out_via = :get

The browser's console log gives me this error:

POST http://localhost:3000/users/sign_out 404 (Not Found)

And the Rails log show me this:

Started DELETE "/users/sign_out" for ::1 at 2022-03-06 11:07:46 -0600
  
ActionController::RoutingError (No route matches [DELETE] "/users/sign_out"):

Is there anything I still need to check? Please advise.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source