如何设置从资源到资源的路由前缀?

时间:2017-05-06 15:31:17

标签: ruby-on-rails ruby rest routes

我有一个这样的rails路由配置,当我运行rake routes时它会显示,但我想这个perfix是restore_link,我怎么能这样做?

佣金路线

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

routes config

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

1 个答案:

答案 0 :(得分: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