如何定义路由,以获得以下结果:
new_ad GET /ads/new/:type(.:format) ads#new
ads POST /ads(.:format) ads#create
edit_ad GET /ads/:id/edit(.:format) ads#edit
ad GET /ads/:id(.:format) ads#show
PUT /ads/:id(.:format) ads#update
DELETE /ads/:id(.:format) ads#destroy
一般来说,我需要在新路径中指定类型参数,并且能够像这样使用路径助手:
new_ad_path("somytype") # -> ads/new/somytype -> ads#new -> params[:type] = "somytype"