当url需要传递两个id值的时候需要用到嵌套路由
实例:
routes.rb中:
resources :coupons do
resources :user_coupons
end
在routes的目录中(注意看对应关系!!!!):
manage_coupon_user_coupons_path | GET | /manage/coupons/:coupon_id/user_coupons(.:format) | manage/user_coupons#index |
POST | /manage/coupons/:coupon_id/user_coupons(.:format) | manage/user_coupons#create | |
new_manage_coupon_user_coupon_path | GET | /manage/coupons/:coupon_id/user_coupons/new(.:format) | manage/user_coupons#new |
edit_manage_coupon_user_coupon_path | GET | /manage/coupons/:coupon_id/user_coupons/:id/edit(.:format) | manage/user_coupons#edit |
manage_coupon_user_coupon_path | GET | /manage/coupons/:coupon_id/user_coupons/:id(.:format) | manage/user_coupons#show |
PATCH | /manage/coupons/:coupon_id/user_coupons/:id(.:format) | manage/user_coupons#update | |
PUT | /manage/coupons/:coupon_id/user_coupons/:id(.:format) | manage/user_coupons#update | |
DELETE | /manage/coupons/:coupon_id/user_coupons/:id(.:format) | manage/user_coupons#destroy |