Search code examples
ruby-on-railsrails-routing

Why does Rails delete method get routed to GET instead of DELETE?


I am getting, the following routing error, i am not sure why it is not routing to DELETE and goes to GET

No route matches [GET] "/signout"

html.erb:

<%= link_to "Sign out", signout_path, method: "delete" %>

routes.rb:

  match '/signout', to: 'sessions#destroy', via: :delete

What command am i missing?


Solution

  • You want to ensure you have the jquery_ujs file loaded as part of your application.js manifest. I believe in older versions of Rails it is known as rails_ujs.


    application.js

    // ...
    //= require jquery_ujs
    // ...