I’m new to Rails and I’m working through a simple app that has the following routes:
resources :mothers do
resources :kids
end
On the kids show.html.erb page, I’m displaying the mother of the kid and have a link that links back to the mother:
Mother: <%= @kid.mother.full_name %>
<%= link_to raw('View'), mother_path %>
However, this seems to redirect to a path mother/:id where :id is the :id of mother is actually the :id of kid.
How do I correct the route so that it links to the proper mother of the child via the ID?
I’ve tried
<%= link_to raw('View'), mother_path(mother) %>
and it says “undefined local variable or method.” Am I missing something in my controller?
or