in routing
resources :departments do
resources :buildings do
resources :halls do
end
resources :chairs do
resources :buildings do
resources :halls do
end
end
end
I want to share the same views of buildings and halls between chairs and departments. And I am thinking to create url’s in views this way:
link_to "Show", [@department, @chair, @building, @hall].compact
If @chair doesn’t exist, it’s gonna be nil, so upper link will generate:
link_to "Show", [@department, @building, @hall]
If @chair exist:
link_to "Show", [@department, @chair, @building, @hall]
My question is: How to create this way url’s to edit, or new action? Or maybe there exist better solution for this problem with this kind of nested resources?
You can stick a symbol in the array as well. So something like this: