I have a model Model that can be access from many ways: by subdomain or a token
I have the following routes
resources :model, :constraints => {:model_id => /[a-zA-Z0-9]{4}/} do
... (nested resources...)
end
resources :model, :constraints => {:subdomain => /.+/} do
... (same as above: nested resources...)
end
So I currently have to duplicate all the routes for the two cases.
Is there any way to declare it only once?
def nested_routes
get :some_route
post :some route
resources :some_resources
end
resources :model, :constraints => {:model_id => /[a-zA-Z0-9]{4}/} do
nested_routes
end
resources :model, :constraints => {:subdomain => /.+/} do
nested_routes
end
Related topic: Rails 3 Routes: DRY members
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