私が考えることができる最善の解決策は、#update と #destroy にマップされた 2 つの新しいメンバー ルートを追加することでした。
resources :posts do
member do
post :revise, :action => :update
post :annihilate, :action => :destroy
end
end
「rake routes」を実行すると、これらのルートが追加されます。
revise_post POST /posts/:id/revise(.:format) {:action=>"update", :controller=>"posts"}
annihilate_post POST /posts/:id/annihilate(.:format) {:action=>"destroy", :controller=>"posts"}
私が最初にこれを試したことに注意してください:
resources :posts do
member do
post :update
post :destroy
end
end
これらのルートが作成されることを期待しています:
update_post POST /posts/:id/update(.:format) {:action=>"update", :controller=>"posts"}
destroy_post POST /posts/:id/destroy(.:format) {:action=>"destroy", :controller=>"posts"}
しかし、代わりに作成しました:
POST /posts/:id(.:format) {:action=>"update", :controller=>"posts"}
POST /posts/:id(.:format) {:action=>"destroy", :controller=>"posts"}
それらが重なっているように見え、posts#destroy に到達できませんでした。