3

我刚刚完成从 rails 2.3.5 到 rails 3.2.6 的升级,我在 Windows 上使用 ruby​​ 1.8.7 并且我当前的路由不再有效。有人可以指导我了解 3.2.6 的新格式吗,我对 match 的工作方式有点困惑。

ActionController::Routing::Routes.draw do |map|
  map.resources :uom_conversions
  map.connect 'delete_old_data/delete_data', :controller => "items", :action => "delete_data"
  map.connect 'delete_old_data', :controller => "items", :action => "delete_old_data"
  map.connect 'pricelist_import', :controller => "items", :action => "pricelist_import"
  map.connect 'pricelist_import/match_pricelist_columns', :controller => "items", :action => "match_pricelist_columns"
  map.connect 'commit_pricelist', :controller => "items", :action => "commit_pricelist"
  map.connect 'pricelist_tool', :controller => "items", :action => "pricelist_tool"
  map.connect 'cross_reference_import', :controller => "items", :action => "cross_reference_import"
  map.connect 'commit_cross_references', :controller => "items", :action => "commit_cross_references"
  map.connect 'import_file/commit_import', :controller => "items", :action => "commit_import"
  map.connect 'import_file', :controller => "items", :action => "import_file"
  map.connect 'import_file/match_columns', :controller => "items", :action => "match_columns"
  map.connect 'set_default_matches', :controller => "items", :action => "set_default_matches"
  map.connect 'save_default_matches', :controller => "items", :action => "save_default_matches"
  map.connect 'search', :controller => "items", :action => "search"
  map.connect 'search/import_search_file', :controller => "items", :action => "import_search_file"
  map.connect 'search/import_search_file/pick_search_column', :controller => "items", :action => "pick_search_column"
  map.connect 'items/create_uom', :controller => "items", :action => "create_uom"
  map.connect 'items/remove_uom/:uom_id', :controller => "items", :action => "remove_uom"
  map.connect 'items/show_cross_references/:id', :controller => "items", :action => "show_cross_references"


  map.resources :items

  map.resources :vendors

  map.resources :manufacturers

  map.resources :sub_categories

  map.resources :categories

  map.resources :hospitals

  map.resources :ministry_organizations

  map.resources :agreements



  map.connect 'users/change_password', :controller => "users", :action => "change_password"
  map.connect 'users/update_password', :controller => "users", :action => "update_password"
  map.resources :users

  map.logout '/logout', :controller => 'login', :action => 'logout'
  map.logout '/switch_admin', :controller => 'login', :action => 'switch_admin'
4

1 回答 1

7

map.resources :items变成resources :items

所有符合此格式的行:

map.connect 'delete_old_data/delete_data', :controller => "items", :action => "delete_data"

变得

match 'delete_old_data/delete_data', :to => "items#delete_data"

这:

map.logout '/logout', :controller => 'login', :action => 'logout'

会成为

match "/logout", :to => "login#logout", :as => :logout
于 2012-07-15T02:31:27.283 回答