2014-02-25 36 views
0

我是RoR的新手,我在這裏與路由掙扎。我需要的是讓我的應用程序中獲得這樣的路線:當它的嵌套RoR時只允許訪問路由

root/trip/:id/destination 

但否認路線是這樣的:

root/destination 

我的路線文件看起來像這樣:

resources :destinations 
    resources :trips do 
    resources :destinations 
    end 
    root to: "trips#index" 

,當我走從嵌套鏈接斷開的路由中排除第一行。我試圖做到的是先從

-> /root/trip(with linke to new file with new view) 
-> /root/show_all_destinations (with its own index and show action) and than 
-> /root/show_all_destination/:id (without edit/new/delete) 
+0

請閱讀更多關於抹紅的http://guides.rubyonrails。組織/ routing.html。它會幫助你很多。 –

+0

我這樣做,但我的代碼中有其他問題。我解決了它,現在拒絕從根作品... – user2945241

回答

0
resources :trips 
    resources :destinations 
end 

如果你不喜歡上面,它會拒絕root/destination但將允許root/trip/:id/destination

+0

好的謝謝...幫助。現在我無法訪問從根目錄到目的地! – user2945241