2

我正在将应用程序从 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 中重现这些路线?

谢谢!

4

1 回答 1

1

经过一次尝试,我成功地使它与以下代码行一起工作:

scope '/soumission/VT/:page_id' do
    get 'police/new', controller: :soumission_vt, action: :new, as: :new_soumission_vt
end

希望这能帮助您及时完成迁移!

;)

于 2016-03-31T19:33:10.590 回答