I have an Array of various ActiveRecord Objects which are Objects of different Models. One of them is called Team
which is a nested ressource of Department
:
resources :departments do
resources :teams
end
So when I use this in the array.each
like this:
array.each do |element|
link_to element.name, element
end
It throws an error that team_path
doesnt exist whats logical because of nested ressources the route is called department_team_path
but I cant call this method absolutely because I also treat Objets of other Models in this each
.
One posibility I see is to add a Route called team_path whih refers to Team#Show but thats not pretty and also bad for the SEO. Is there another better possibility to link to this and other models in one course?