This article uses Ruby 2.6.5 installed on macOS Catalina 10.15.6.
On the report list screen, click the image of the posted report to see the details.
To transition to the details screen when clicking the image, you can solve it by using nesting in the link_to method. Enclose in do ~ end
.
html:index.html.erb
<%= link_to report_path(report.id) do %>
<div class="content_post">
<%= image_tag report.image if report.image.attached? %>
<p>Customer name:<%= report.name %></p>
<span class="name">
<%= report.date %>
</span>
</div>
<% end %>
Nesting is a very useful feature because you can specify which report to comment on when setting up routing! I hope it helps people with similar worries and bumps into the wall!
Recommended Posts