0

我有以下资源块

resources :projects, :except => [:destroy] do
  resources :tasks, :except => [:index]
  get "tasks/:id/change_state" => "tasks#change_state", :as => "task_change_state"
  get "tasks/:id/assign_user"  => "tasks#assign_user",  :as => "task_assign_user"
  get "tasks/:id/unassign"      => "tasks#unassign",     :as => "task_unassign"
end

我想知道如何在不触及路径的情况下稍微重构这些路线。我尝试执行以下操作:

resources :projects, :except => [:destroy] do
  resources :tasks, :except => [:index] do
    member do
      get 'change_state'
      get 'assign_user'
      get 'task_unassign'
    end
  end
end

但这会使带有任务的路由方法名称成为复数形式。我需要 URL 是复数,就像在原始的 get 方法调用中一样。但是我需要方法名称是单数的,因为我不想更改整个应用程序的实现。

4

0 回答 0