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

Rails routing error: [DELETE] "/logout"

I'm working my way through the testing phase of the whole app and after going to the '/logout' url it throws me this error in response:

No route matches [DELETE] "/logout"

My routes.rb file is fine, I've double and triple checked. Even the ruby -Itest seems to indicate that the route functions as it should.

Any Ideas?

4 Answers

Matt West
Matt West
14,545 Points

Hi Christopher,

Can you please post your routes.rb file.

Treebook::Application.routes.draw do devise_for :users

devise_scope :user do get "register", :to => "devise/registrations#new", as: :register get "login", :to => "devise/sessions#new", as: :login get "logout", :to => "devise/sessions#destroy", as: :logout end

resources :statuses get "feed", :to => "statuses#index", as: :feed root :to => "statuses#index"

Matt West
Matt West
14,545 Points

Try changing this line:

get "logout", :to => "devise/sessions#destroy", as: :logout

to:

delete "logout", :to => "devise/sessions#destroy", as: :logout

It seems that the code wasn't the problem after all. After clearing the cache and a reboot the function worked perfectly with the GET method.

Thanks for the help.