users_path(user) returns /users.id instead of /users/id when using devise

此生再无相见时 提交于 2019-12-11 02:13:15

问题


I find that when I use users_path(user) it returns /users.id where id is the id of the user but I want it to return /users/id. My config routes.rb looks like the following.

# config/routes.rb
Test::Application.routes.draw do
  root to: "static_pages#home"
  resources :users, only: [:index, :show]

  devise_for :users
end

回答1:


Use this for a path to a singular user:

user_path(user)

Use this for a path to all the users, or the index page:

users_path # no arguments


来源:https://stackoverflow.com/questions/14300865/users-pathuser-returns-users-id-instead-of-users-id-when-using-devise

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!