LoginSignup
0
0

More than 1 year has passed since last update.

【Rails, Active Storage】  画像が割れて表示されてしまった件

Last updated at Posted at 2022-01-08

実行内容

Active Storageを使ってアップロード済のユーザーアイコン画像を、
以下のコードにより表示させようとした。

<% if @user.avatar.attached? %>
  <%= image_tag @user.avatar, size: "100x100" %>
<% end %>

問題点

以下のように割れた画像が表示された。
スクリーンショット 2022-01-09 1.33.04.png

解決策

以下のようにコードを修正し、うまく表示された。

<% if @user.avatar.attached? %>
  <%= image_tag url_for(rails_blob_path(@user.avatar)), size: "100x100" %>
<% end %>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0