Rails 5路由 - 如何在众多资源之间共享一条公共路由?

时间:2016-11-08 16:56:50

标签: ruby-on-rails

我有很多资源需要在销毁记录之前拥有删除视图,例如:

resources :assignments do
    get 'delete'
  end

  resources :occupations do
    get 'delete'
  end

  resources :extra_shifts do
    get 'delete'
  end

  resources :events do
    get 'delete'
  end

有没有办法可以干这个?

我知道Routing Concerns,但是这样我只需将路线移到街区外,并将其设置在资源线旁边,这可以节省一些线路,但仍然有很多重复。

1 个答案:

答案 0 :(得分:0)

非常确定

resources :assignments, :events,
 :occupations, :extra_shifts do
  get 'delete'
end

会起作用