Today, I will summarize what I was learning and took about 30 minutes to solve.
Even if you want to go to the detail page, you do not jump to the page you want, and even if you touch any link image, you will go to the same detail page.
def show
@prototype = Prototype.find(params[:id])
end
I think that the action of the controller is wrong, and I look back many times, but I can't find any problem. Find the id in the Prototype table and put it in an instance variable.
Next, to see the code of the part to touch when jumping to the detail page.
<%= link_to image_tag(prototype.image), prototype_path(prototype.user.id)%>
Yes, I wanted to find the id of the prototype
by putting the .user
in the linked path, but I was looking for the id of the ʻuser` table. So, when I entered as a user with id = 1, I was on the first detail page no matter which link image I touched. A mistake that occurred because the prototype table and the user table are associated.
Correctly ↓
<%= link_to image_tag(prototype.image), prototype_path(prototype.id)%>
Recommended Posts