2017-05-06 103 views
0

我有一個像這樣的rails路由配置,當我運行rake routes它表明,但我想perfix是restore_link,我該怎麼做?如何設置從資源到資源的路由前綴?

耙路線

restore_links POST /:uid/links/:id(.:format)     links#restore 

路由配置

resources :accounts, path: '/', param: :uid, only: [:show] do 
    member do 
    resources :links do 
     collection do 
     post ':id', to: "links#restore", as: "restore" 
     end 
    end 
    end 
end 
+0

你得到這個工作嗎? –

+0

不,我最終使用'post':uid/links /:id'來:「links#restore」,如:「restore_link」'在資源塊外 – Tsao

+0

我想自定義perfix不是url路徑 – Tsao

回答

2
resources :accounts, path: '/', param: :uid, only: [:show] do 
    member do 
    resources :links, path: 'restore_links' do # <========= `path` option 
     collection do 
     post ':id', to: "links#restore", as: "restore" 
     end 
    end 
    end 
end