wrburgess wrburgess - 1 month ago 5x
Ruby Question

Devise routes issue in Rails 3.1 with No route matches [GET] "/users/sign_out"

I am using the Devise 1.4.9 authentication gem with my Rails 3.1 app and when I click on any link I get routing errors. Here's what happens when I click on the Sign Out link:

Routing Error

No route matches [GET] "/users/sign_out"

I am creating the link with this method:

<%= link_to('Sign Out', destroy_user_session_path, :method => :delete) %>

This is how the link is rendered in the source:

<a href="/users/sign_out" data-method="delete" rel="nofollow">Sign Out</a>

I have this line in my layout header:

<%= javascript_include_tag :defaults %>

These lines are in my application.js file:

// = require jquery
// = require jquery_ujs
// = require_tree .

Here is the relevant rake routes output:

new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session DELETE /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
cancel_user_registration GET /users/cancel(.:format) {:action=>"cancel", :controller=>"devise/registrations"}
user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"devise/registrations"}
PUT /users(.:format) {:action=>"update", :controller=>"devise/registrations"}
DELETE /users(.:format) {:action=>"destroy", :controller=>"devise/registrations"}

I've tried pretty much everything in this thread to no avail:

No route matches "/users/sign_out" devise rails 3

I've restarted the server numerous times.

This issue seems to have come up in the past, but not a single solution described has changed this behavior and I'm stumped.


Please try to rename :defaults to :application when passing it to javascript_include_tag in case you define your includes in application.js

<%= javascript_include_tag :application %>