开发者

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

开发者 https://www.devze.com 2023-01-16 02:35 出处:网络
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.

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.

It's there something wrong with my codes? Or a bug in rails?


The namespace isn't typically added to the method that returns the route. So you probably have a route whatever_posts_path. The rake task rake routes is particularly useful in these cases. The first part of the display for each route is the name of the method you can use to access it (if available).

0

精彩评论

暂无评论...
验证码 换一张
取 消