问题
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