仅发送数值时未找到Rails 3.2路由

时间:2012-11-15 15:30:10

标签: ruby-on-rails-3 routes

我有这条路线:

match 'items/:location_no/:item_no' => 'items#location_item', :constraints => { :location_no => /.*/, :item_no => /.*/ }

我通过以下链接调用它:http://localhost:3000/items/whs/65484 这给了我这个错误:

No route matches {:action=>"edit", :controller=>"item_details"}

项目编号(它不是id字段)是65484但如果我将其更改为有一个字母如65484s(http://localhost:3000/items/whs/65484s),它会进入正确的控制器(尽管它找不到该项目,因为最后的虚假 s )什么可能导致它只与数字不匹配的路线?我试图以相同的效果跳过路线中的约束。

根据要求,这些是项目路线:

             item_details GET    /item_details(.:format)                          item_details#index
                          POST   /item_details(.:format)                          item_details#create
          new_item_detail GET    /item_details/new(.:format)                      item_details#new
         edit_item_detail GET    /item_details/:id/edit(.:format)                 item_details#edit
              item_detail GET    /item_details/:id(.:format)                      item_details#show
                          PUT    /item_details/:id(.:format)                      item_details#update
 autocomplete_item_name_items GET    /items/autocomplete_item_name(.:format)          items#autocomplete_item_name
       edit_item_history_item GET    /items/:id/edit_item_history(.:format)           items#edit_item_history
                        items GET    /items(.:format)                                 items#index
                              POST   /items(.:format)                                 items#create
                     new_item GET    /items/new(.:format)                             items#new
                    edit_item GET    /items/:id/edit(.:format)                        items#edit
                         item GET    /items/:id(.:format)                             items#show
                              PUT    /items/:id(.:format)                             items#update
                              DELETE /items/:id(.:format)                             items#destroy
                                     /items/:location_no/:item_no(.:format)           items#location_item {:location_no=>/.*/}

0 个答案:

没有答案