Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 奇怪的Rails资源路由行为_Ruby On Rails_Rails Routing - Fatal编程技术网

Ruby on rails 奇怪的Rails资源路由行为

Ruby on rails 奇怪的Rails资源路由行为,ruby-on-rails,rails-routing,Ruby On Rails,Rails Routing,我遇到了奇怪的错误。我不确定这是错误。然而,我以前从未见过这种奇怪的行为 resource :watches 使路由表变得如此奇怪: watches POST /watches(.:format) watches#create new_watches GET /watches/new(.:format) watches#new edit_watches GET

我遇到了奇怪的错误。我不确定这是错误。然而,我以前从未见过这种奇怪的行为

resource :watches
使路由表变得如此奇怪:

        watches POST   /watches(.:format)                         watches#create
    new_watches GET    /watches/new(.:format)                     watches#new
   edit_watches GET    /watches/edit(.:format)                    watches#edit
                GET    /watches(.:format)                         watches#show
                PUT    /watches(.:format)                         watches#update
                DELETE /watches(.:format)                         watches#destroy
如您所见,没有ID参数和混乱的操作

同时:

resources :mibs
走正路

           mibs GET    /mibs(.:format)                            mibs#index
                POST   /mibs(.:format)                            mibs#create
        new_mib GET    /mibs/new(.:format)                        mibs#new
       edit_mib GET    /mibs/:id/edit(.:format)                   mibs#edit
            mib GET    /mibs/:id(.:format)                        mibs#show
                PUT    /mibs/:id(.:format)                        mibs#update
                DELETE /mibs/:id(.:format)                        mibs#destroy
我认为这可能是某种程度上的拐点问题,但尝试使用“火箭”而不是“手表”会得到同样的结果:

        rockets POST   /rockets(.:format)                         rockets#create
    new_rockets GET    /rockets/new(.:format)                     rockets#new
   edit_rockets GET    /rockets/edit(.:format)                    rockets#edit
                GET    /rockets(.:format)                         rockets#show
                PUT    /rockets(.:format)                         rockets#update
                DELETE /rockets(.:format)                         rockets#destroy
除了我的前两个资源(服务器和MIB)之外的任何东西都会产生这样的结果


可能是某个地方的路由缓存损坏了?

resource
表示一个单例资源:换句话说,您告诉Rails每个用户只有一个手表,所以传递ID是没有用的

resources
是获取附加ID的路由的标准调用


因此,本质上,问题是一个拐点,但对于
资源
资源
,而不是路线名称。有关更多信息,请查看。它很好地解释了单例资源和更常见资源之间的区别。

谢谢。我自己刚找到一个。我应该多睡一会儿:)没问题,容易错过的事!