Home>
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.
Create for image posting
class PhotopostsController</pre>
<strong>Partial for posting images</strong>
<pre><code><% = form_for (@photopost) do | f |%>
<span>
<% = f.file_field: picture%>
</span>
<% = f.text_area: content, placeholder: "Add comment"%>
<% = f.submit "Post", class: "btn btn-success"%>
<% end%>
Partial drawing the saved image and content
<li>
<% = link_to gravatar_for (@ photopost.user, size: 50)%>
<span><% = link_to @ photopost.user.name, photopost_path%></span>
<span>
<% = image_tag @ photopost.picture.url if @ photopost.picture?%>
<% = @ photopost.content%>
</span>
<span>
<% = link_to "delete", photopost, method:: delete,
data: {confirm: "You sure?"}%>
</span>
</li>
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
Related articles
- ruby on rails - about image posting page argumenterror
- ruby on rails - i want to post an image by dragging and dropping
- ruby - [rails] i want to create an image link using the url of the image output using active storage
- ruby on rails - about image distribution on heroku and s3
- ruby on rails - image cannot be saved (activestorage installed) null in image of table
- ruby on rails - i want to create an image posting function with react (typescript), formik, rails api, activestorage
- ruby on rails - creating a follow function i don't understand the error
- ruby on rails 5 - after overwriting the image under assets, nothing is displayed
- ruby - i installed carrierwave with rails, but i can't see the image
- ruby on rails 5 - rails522 creating a bulletin board: please tell us about posting comments!
- ruby on rails 5 - some items are not saved in db when posting from rails form
- ruby - when posting an image, an error occurs where the image is not defined
- ruby on rails - comment posting function actioncontroller :: urlgenerationerror
- ruby on rails - i cannot save a comment on the comment posting page
- ruby - rails i want to make the created_at time the same when creating multiple data at once
- ruby on rails - i want to display the posted image in the background using image_tag or url_for
- ruby on rails - [rails] the initial image of the icon for the user is not displayed
- ruby on rails - the image cannot be saved in s3 and cannot be displayed in the view aws :: sigv4 :: errors :: missingcredentials
- ruby on rails - i want to display the latest posting date and time by creating a simple bulletin board
Trends
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable
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.