I am working on a new rails application and came to this scenario. I want same routes in multiple resources but I don't want to repeat the same lines.
Is there any way to DRY up this
resources :contacts do
collection do
post :associate
delete :remove
end
end
resources :doctors do
collection do
post :associate
delete :remove
end
end
Any help will be appreciated.
Try:
concern :associate do
collection do
post :associate
delete :remove
end
end
resources :contacts, :concerns => [:associate]
resources :doctors, :concerns => [:associate]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With