I want to display images in rails.

Asked 2 years ago, Updated 2 years ago, 41 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>
    <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%>

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


© 2024 OneMinuteCode. All rights reserved.