多个资源中的相同路线
Same routes in multiple resources
我正在开发一个新的 rails 应用程序并遇到了这种情况。我想要多个资源中的相同路线,但我不想重复相同的线路。
有什么办法可以干掉这个
resources :contacts do
collection do
post :associate
delete :remove
end
end
resources :doctors do
collection do
post :associate
delete :remove
end
end
任何帮助将不胜感激。
尝试:
concern :associate do
collection do
post :associate
delete :remove
end
end
resources :contacts, :concerns => [:associate]
resources :doctors, :concerns => [:associate]
我正在开发一个新的 rails 应用程序并遇到了这种情况。我想要多个资源中的相同路线,但我不想重复相同的线路。
有什么办法可以干掉这个
resources :contacts do
collection do
post :associate
delete :remove
end
end
resources :doctors do
collection do
post :associate
delete :remove
end
end
任何帮助将不胜感激。
尝试:
concern :associate do
collection do
post :associate
delete :remove
end
end
resources :contacts, :concerns => [:associate]
resources :doctors, :concerns => [:associate]