ruby-on-rails – Rails忽略了收集路线,而与show action相反
发布时间:2020-12-16 22:17:19 所属栏目:百科 来源:网络整理
导读:我的route.rb文件中设置了以下路由: resources :people do collection do get :search endend 当我对url:http://localhost:3000/people/search.json?term=stepeb采取行动时, 服务器报告它使用show操作进行响应,具有正确的术语参数,但也具有设置为“search
我的route.rb文件中设置了以下路由:
resources :people do collection do get :search end end 当我对url:http://localhost:3000/people/search.json?term=stepeb采取行动时, 这个问题,正如我所看到的,是两个网址 /people/:id 我相信路由器在获得/ people / search之前匹配该路由 如果是这样,基于路由的路由将如何工作?他们都不会被演出动作所捕获吗? 耙路的相关部分如下: search_people GET /people/search(.:format) {:action=>"search",:controller=>"people"} GET /people(.:format) {:action=>"index",:controller=>"people"} people POST /people(.:format) {:action=>"create",:controller=>"people"} new_person GET /people/new(.:format) {:action=>"new",:controller=>"people"} GET /people/:id(.:format) {:action=>"show",:controller=>"people"} PUT /people/:id(.:format) {:action=>"update",:controller=>"people"} person DELETE /people/:id(.:format) {:action=>"destroy",:controller=>"people"} edit_person GET /people/:id/edit(.:format) {:action=>"edit",:controller=>"people"} 解决方法
Doh,忘了这一个.原来我有一个重复的资源:人们在路线文件的顶部. Rails是第一个.似乎对我来说真的应该在那里检查重复的路由定义.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |