我正在将应用程序从 Rails 2.3.5 迁移到 Rails 3.2.8。我有来自 Rails 2 应用程序的这条路线,这让我很头疼:
map.resources :soumission_vt,
:path_prefix => "/soumission/VT/:page_id", :as => 'police/:action/:id',
:requirements => {:page_id => /\S+/}
至极生成以下内容:
soumission_vt_index GET /soumission/VT/:page_id/police/:action/:id(.:format) {:controller=>"soumission_vt"}
POST /soumission/VT/:page_id/police/:action/:id(.:format) {:controller=>"soumission_vt"}
new_soumission_vt GET /soumission/VT/:page_id/police/:action/:id/new(.:format) {:controller=>"soumission_vt"}
edit_soumission_vt GET /soumission/VT/:page_id/police/:action/:id/:id/edit(.:format) {:controller=>"soumission_vt"}
soumission_vt GET /soumission/VT/:page_id/police/:action/:id/:id(.:format) {:controller=>"soumission_vt"}
PUT /soumission/VT/:page_id/police/:action/:id/:id(.:format) {:controller=>"soumission_vt"}
DELETE /soumission/VT/:page_id/police/:action/:id/:id(.:format) {:controller=>"soumission_vt"}
我在 Rails 3 中这样翻译它:
scope '/soumission/VT/:page_id', :constraints => {:page_id => /\S+/} do
resources :soumission_vt, :as => 'police/:action/:id'
end
但我得到一个无效的路由名称:'police/:action/:id_index'...
那么有没有办法在 Rails 3 中重现这些路线?
谢谢!