资源路线成员。具有奇异方法名称的多个网址?

时间:2013-10-08 19:06:00

标签: ruby-on-rails ruby-on-rails-3

我有以下资源块

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方法调用中一样。但我需要方法名称是单数,因为我宁愿不改变整个应用程序的实现。

0 个答案:

没有答案