Currently, when I set to upload images to S3 using Active Storage in the production environment, the images are not displayed properly and I am in trouble.
However, the image is not displayed, but the image can be posted.
Since I can post images, I thought that there was no problem with the access key and secret key settings, and when I checked the console, the following error occurred. Also, in IAM User, I set a User who has administrator privileges.
Thanks for your understanding.

Path 500 under GET
Corresponding source code


<% if current_user.profile&&current_user.profile.avatar.attached?%>
<% = image_tag current_user.profile.avatar.variant (resize_to_fill: [a, b])%>
<% else%>
<% = image_tag'xxxx.jpg'%>
<% end%>
What I tried

-First, I tried changing the S3 bucket policy settings, but I noticed that it was not relevant because it was accessed by a user with administrator privileges. Also, since I was able to post the image to s3, I thought that there was no problem with the settings there.

-I found that the path generated by image_tag is not the path to S3, so I tried image_tag ulr_for (...), but it didn't work.

<% if current_user.profile&&current_user.profile.avatar.attached?%>
<% = image_tag url_for (current_user.profile.avatar.variant (resize_to_fill: [a, b]))%>
<% else%>
<% = image_tag'xxxx.jpg'%>
<% end%>

Is it difficult to set up S3 in a production environment? Is it just missing something more basic?


  • Answer # 1

    It was due to S3 settings and linux2 not having ImageMagick!

Related articles