I want to display images in rails.

Asked 2 months ago, Updated 2 months ago, 3 views

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.

Enter a description of the image here

<img src="<%="/#{post.user.image_name}"%>">
    <div class="post-right">
      <div class="post-user-name">
        <!--Create a link to the user details page using the link_to method -->

        <%=link_to(post.content, "/posts/#{post.id}")%>

        <%[email protected]?%>>! -- Run if you have an uploaded image -->
            <%[email protected]%><!--Retrieves and displays the URL of the image file for the user instance-->




ruby-on-rails ruby

2022-09-30 11:20

1 Answers

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.

2022-09-30 11:20

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.