我能想到的最好的解決辦法是添加映射到#UPDATE兩個新成員的路線和#destroy:
resources :posts do
member do
post :revise, :action => :update
post :annihilate, :action => :destroy
end
end
當你運行「耙路線」,這添加了這些路線:
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"}
看起來像它們是重疊的,你永遠無法得到的帖子#摧毀。