我有一个task_list模型,它有一些像archive和destroy这样的动作。我想像这样路由它们:
resources :task_lists, only: [:create, :update] do
member do
delete '' => 'task_lists#archive'
delete 'destroy' => 'task_lists#destroy'
end
end
但rake routes
为两者提供相同的路线。
DELETE /api/0.0/task_lists/:id(.:format) task_lists#archive {:format=>:json}
task_list DELETE /api/0.0/task_lists/:id(.:format) task_lists#destroy {:format=>:json}
所以我该怎么办?
谢谢!
答案 0 :(得分:0)
试试这个。
delete 'task_lists/:id/destroy(.:format)', :to => 'task_lists#destroy', :as => :destroy_task
delete 'task_lists/:id(.:format)', :to => 'task_lists#archive', :as => :archive_task