我正在开发一个新的rails应用程序并且遇到了这种情况。我希望在多种资源中使用相同的路线,但我不想重复相同的路线。
有没有办法干掉这个
resources :contacts do
collection do
post :associate
delete :remove
end
end
resources :doctors do
collection do
post :associate
delete :remove
end
end
任何帮助将不胜感激。
答案 0 :(得分:7)
尝试:
concern :associate do
collection do
post :associate
delete :remove
end
end
resources :contacts, :concerns => [:associate]
resources :doctors, :concerns => [:associate]