我有一个订阅控制器,其路由如下所示:
get 'user/:user_id/subscription_requests' => 'subscriptions#index', as: :subscription_requests
post 'user/:user_id/subscribe' => 'subscriptions#subscribe', as: :user_subscribe
post 'user/:user_id/unsubscribe' => 'subscriptions#unsubscribe', as: :user_unsubscribe
post 'user/:user_id/request_subscription' => 'subscriptions#request_subscription', as: :request_user_subscription
post 'user/:user_id/accept_subscription' => 'subscriptions#accept', as: :accept_subscription_request
post 'user/:user_id/reject_subscription' => 'subscriptions#reject', as: :reject_subscription_request
除了index
不平静的动作之外,所有这些动作。你如何在路径文件中使用类似的东西使这个更干净,resources
同时保持user/:user_id/
路径?
为清楚起见更新:
我试图避免逐行列出路线,而是做一些类似 rails 提供的宁静动作的事情。就像是:
resources :subscription_requests, :only => [:subscribe, :unsubscribe, :reject, :accept, etc]