Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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