我能想到的最好的解决办法是添加映射到#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"}
看起来像它们是重叠的,你永远无法得到的帖子#摧毁。