2016-12-18 66 views
0

我試圖改變users模型的控制器和routing.rb的動作,當時指向/users url。這裏是我試圖改變它:如何在rails的根目錄下更改模型的默認路由?

resources :users, only: :show do 
    get 'favorites' => 'routers#client' 
    get 'tours' => 'routers#client' 
    get 'offers' => 'routers#client' 
    get 'open_houses' => 'routers#client' 
    get 'searches' 
end 
get 'users/:id' => 'routers#client' 

favortiestoursoffersopen_houses路線routers_controllerclient行動時,URL,例如/users/:id/favorites等被調用。但是當撥打/user/:id時,它不會映射到routers控制器。我應該如何改變這個控制器的索引路線?

+0

不起作用... –

回答

0

終於通過命中和審判發現它。要路由索引,我們可以做

resources :users, only: :show do 
    get '' => 'routers#client' 
    get 'favorites' => 'routers#client' 
    get 'tours' => 'routers#client' 
    get 'offers' => 'routers#client' 
    get 'open_houses' => 'routers#client' 
    get 'searches' 
end