I have an application with Users, Machines, and Tests.
Users have many Machines and Tests
Machines belong to Users
Tests belong to Machines
*While on the Test Show page, I want to add a link to go to that Test’s parent Machine Show page. *
My TestsController reads:
def show
@test = Test.find(params[:id])
...
end
My Test show page has the following link:
<%= link_to 'Back to Machine', machine_path(@machine) %>
For some reason the link is sending the user to
/machines/test_id
instead of
/machines/machine_id
I think I need something in the TestsController Show section like:
def show
@test = Test.find(params[:id])
@machine = Machine.find(params[:id])
...
end
but it must not be correct because I’m getting errors.
Try something like this