Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Simple Ruby on Rails Application Creating an Authentication System Generating the User Model

Javier Nunez
Javier Nunez
7,529 Points

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

I am trying to open up the /users/sign_up page as is happening in this lesson and it says I am signed in, so I thought I would put redirect to "/users/sign_out" to sign out but I get a Routing Error that says

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

Rails.root: /Users/~/Projects/treebook"

Then it gives me a lists of routes. I am not sure what is happening at all.

1 Answer

Jamie McCaw
Jamie McCaw
5,579 Points

"The reason for the error is that the route is inaccessible using the GET HTTP method. Notice what the relevant line looks like in your rake routes output:

destroy_user_session DELETE /users/sign_out(.:format) Meaning that, if you want to log the user out, you need to send a DELETE request to that url. In rails, you can generate a link that does that like so:

link_to 'Sign out', destroy_user_session_path, :method => :delete

alternatively (although NOT recommended):

link_to 'Sign out', '/users/sign_out', :method => :delete The important part is :method => :delete. Note that a DELETE request is not really supported by browsers, rails is actually POSTing the data, but it sends a special parameter that simulates the DELETE method."

This was found at: here