Rails routing/polymorphism issue - how to model the following
- by 46and2
Hi all,
I have an app where a 'user' belong to a 'client' or a 'vendor' (and client and vendor has_many users). In the admin namespace, I want to administer these users - so an admin would choose a client or a vendor, then nav to that client's or vendor's users. My question is, short of making the user model polymorphic, how could I model/route this?
Here is what I have in terms of routing:
map.namespace :admin do |admin|
admin.resources :clients
admin.resources :vendors
end
I know I could do something like:
map.namespace :admin do |admin|
admin.resources :clients do |client|
client.resources :users
admin.resources :vendors do |vendor|
vendor.resources :users
end
end
But the above would definitely need me to treat the User as polymorphic.
I'm just wondering what you would recommend or what my options are.
Thanks.