2013-07-12 147 views
0

我有以下途徑限制資源路線

resources :analytics do 
collection do 
    get 'group_image' 
    get 'group_tag' 
    get 'group_location' 
    get 'group_time' 
end 

但它也創建默認路由,我不需要。我怎樣才能在這裏限制路線?

回答

1

只使用namespace代替resources

namespace :analytics do 
    get 'group_image' 
    get 'group_tag' 
    get 'group_location' 
    get 'group_time' 
end 
2

你可以這樣做:

resources :analytics, only: [] do 
    collection do 
    get 'group_image' 
    get 'group_tag' 
    get 'group_location' 
    get 'group_time' 
    end 
end 

它會創建自定義的路由,而不是默認的一個。

0

您也可以通過排除默認操作來定義。

resources :analytics, :except => [:new, :create, :destroy, :index] do 
collection do 
    get 'group_image' 
    get 'group_tag' 
    get 'group_location' 
    get 'group_time' 
    end 
end