-2

users_pathuser_path(user1)
我猜前者用于索引操作,后者用于特定用户的显示操作

4

3 回答 3

2

Your expectation is right:

users_pathgives the path to the controller action users#index while

user_path(user1)gives the path to controller action users#show with params[:id] set to user1.id

于 2013-05-28T06:05:59.587 回答
0
users_path returns /users
new_user_path returns /users/new
edit_user_path(:id) returns /users/:id/edit (for instance, edit_user_path(10) returns /users/10/edit)
user_path(:id) returns /users/:id (for instance, user_path(10) returns /users/10)

For more details http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions

于 2013-05-28T06:38:03.840 回答
0
users_path will routes to users#index as you expected

user_path(user) will redirect to users#show if method is get

或者

It will redirect or routes to users#destroy if method is delete 
于 2013-05-28T06:48:32.773 回答