advice
advice

Reputation: 5988

Ruby on Rails - User Devise Routing

I'm having issues with routing with Devise and my Users model. I was trying to get sign_out to work and found an answer that suggested this.

// routes.rb

devise_for :users do
    get '/users/sign_out' => 'devise/sessions#destroy'
    get '/users/sign_in' => 'devise/sessions#create'
end

And while this works for signing out, if I use just that I cannot view a User.

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

However, if I add back resources :users, I run into the first issue where sign_out or sign_in try to view a User.

Couldn't find User with 'id'=sign_out

How do I add /users/index to the devise_for loop?

Thanks for your help.

Upvotes: 1

Views: 410

Answers (1)

Shannon
Shannon

Reputation: 3018

Try adding resources :users after your devise_for block.

You can also use the following:

devise_for :users, path: '', path_names: { sign_in: 'login', sign_out: 'logout'}

Upvotes: 1

Related Questions