Lut
Lut

Reputation: 1533

Rails Routing Error uninitialized constant

I have the following error when trying to log out from an authentication gem I have just install.

http://0.0.0.0:3000/users/sign_out

Routing Error
uninitialized constant UsersController

I dont have a users_controller.rb file. I do have a user.rb Model.

This is the path/url i am trying to reach:

destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy

Any idea?

Upvotes: 2

Views: 6112

Answers (1)

Ivan Zamylin
Ivan Zamylin

Reputation: 1748

Your problem is that devise_for :users is overshadowed by resources :users

Rails complains about UsersController, because it thinks that you are trying to reach users#show (if you use GET request) and users#destroy (if you use DELETE)

enter image description here

You should either create UsersController or remove resources :users from your routes. And if you decide to create UserController, move resources :users under devise_for :users. Devise routes would take precedence that way.

Are you sure that you need resources :users?

Upvotes: 11

Related Questions