简体   繁体   English

关于Rails的路线,将收集路线添加到静态资源不会生成命名路线帮助程序?

[英]about rails' routes, adding collection routes to restful resources won't generate named route helpers?


namespace :admin do
    resources :posts do
        collection do
            get 'whatever'
        end
    end
end

I was expect that will generate 'whatever_admin_posts_path' helper method, but it didn't. 我期望它将生成“ whatever_admin_posts_path”帮助程序方法,但没有。
It's there something wrong with my codes? 我的代码有问题吗? Or a bug in rails? 还是Rails中的错误?

The namespace isn't typically added to the method that returns the route. 通常不将名称空间添加到返回路由的方法中。 So you probably have a route whatever_posts_path . 因此,您可能有一条路线whatever_posts_path The rake task rake routes is particularly useful in these cases. 耙任务rake routes在这些情况下特别有用。 The first part of the display for each route is the name of the method you can use to access it (if available). 每个路线的显示内容的第一部分是可用于访问它的方法的名称(如果有)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM