I am creating an image posting function in Rails, but the image cannot be displayed and there is an error.
I'd like to edit it just in case, but the same error appears.
<img src="<%="/#{post.user.image_name}"%>">
</div>
<div class="post-right">
<div class="post-user-name">
<!--Create a link to the user details page using the link_to method -->
</div>
<%=link_to(post.content, "/posts/#{post.id}")%>
<%[email protected]?%>>! -- Run if you have an uploaded image -->
<p>
<strong>photo:</strong>
<%[email protected]%><!--Retrieves and displays the URL of the image file for the user instance-->
</p>
<%end%>
</div>
</div>
<%end%>
You can see from the error screen that @post
is nil
in the line where the error occurs.Since post
is used in the above line and it is working, it seems that post
is correct.
© 2024 OneMinuteCode. All rights reserved.