答案 0 :(得分:2)
使用收集路线:
resources :appointments do
collection do
get :confirm
get :cancel
get :history
end
end
它会生成appointments/confirm
等路线。
答案 1 :(得分:0)
正如上面的评论所示。您应该使用member
路线:
resources :appointments, only: [:new] do
member do
get :confirm
get :cancel
get :history
end
end
产生以下路线:
confirm_appointment GET /appointments/:id/confirm(.:format) appointments#confirm
cancel_appointment GET /appointments/:id/cancel(.:format) appointments#cancel
history_appointment GET /appointments/:id/history(.:format) appointments#history
new_appointment GET /appointments/new(.:format) appointments#new
如果你想要除new
以外的任何其他内容。只需将其传递到only
数组下。