On my .rb routes, I have:
resources :aquariums do resources :management_roles resources :graphs resources :animals end get 'aquarium', to: 'aquariums#show', :as => :aquarium
The reason for the last receipt - I have the concept of "current aquarium" in my application. If, say, current_aquarium is set to 1, then in my "show" action / aquarium, the "controller" gets the same rendering as "/ aquariums / 1" with a code like
@aquarium_id = params[:id] || current_aquarium.id
Now, and I guess this is due to this other routing, this code:
<%= link_to aquarium.name, aquarium %>
or
<%= link_to aquarium.name, aquarium_path(aquarium) %>
Creates paths as follows:
/aquarium.1
where I usually expect:
/aquariums/1
Right?
Upon request ... here that rake routes | grep aquar rake routes | grep aquar gives: (I assume this is the very last route that confuses things, but I would have thought it would handle them in order. And, just FYI, I originally had this route at the top. would be fixed).
aquarium_management_roles GET /aquariums/:aquarium_id/management_roles(.:format) management_roles#index POST /aquariums/:aquarium_id/management_roles(.:format) management_roles#create new_aquarium_management_role GET /aquariums/:aquarium_id/management_roles/new(.:format) management_roles#new edit_aquarium_management_role GET /aquariums/:aquarium_id/management_roles/:id/edit(.:format) management_roles#edit aquarium_management_role GET /aquariums/:aquarium_id/management_roles/:id(.:format) management_roles
Thanks in advance!
Greg
source share