I entered the contents in the file_field (for images) and text_area (for contents) created by form_for and saved it, but the image and the contents entered in the text_area are not drawn and the empty post and delete links are not saved. Will only be drawn.
Even if you check it with the developer tool, the content is empty, and the image is not drawn if there is no image data with the postfix if, so it is not drawn.

Controller with create action for posting images
Create for image posting
class PhotopostsController</pre>
<strong>Partial for posting images</strong>
<pre><code><% = form_for (@photopost) do | f |%>
  <% = f.file_field: picture%>
  <% = f.text_area: content, placeholder: "Add comment"%>
<% = f.submit "Post", class: "btn btn-success"%>
<% end%>
Partial drawing the saved image and content
<% = link_to gravatar_for (@ photopost.user, size: 50)%>
<span><% = link_to @ photopost.user.name, photopost_path%></span>
  <% = image_tag @ photopost.picture.url if @ photopost.picture?%>
  <% = @ photopost.content%>
 <% = link_to "delete", photopost, method:: delete,
                                      data: {confirm: "You sure?"}%>
It is an additional part of the controller method ← 2) that calls the view to be drawn.
class MypagesController
Photopost model
class Photopost
User model
class User
  • Answer # 1

    Originally I was trying to implement the image posting function and displaying the posted image on the show page, but based on the Rails tutorial, if the LP is logged in, make it the image posting view and show By displaying the posted image and the entered text, the view of was saved and drawn safely.

Related articles