LoginSignup
0
0

image_tag が本番環境で使えない

Last updated at Posted at 2024-06-06

はじめてのデプロイ

いよいよフェーズ1のデプロイ!
コマンドをちょこちょこ打って終わった!と思ったらエラーが起きた!
けど解決したのでまとめます。

image_tagは使えない?

<%= image_tag %>を使用して画像を表示させていたものの、本番環境ではエラーが起きました。
問題の記述はこちら↓

top.html.erb
<%= image_tag "go_out_planning_logo.png", size: "250x250", class: "rounded-circle mx-auto mb-3 d-block" %>

これを本番環境用に修正すると…

top.html.erb
<%= image_tag asset_path('go_out_planning_logo.png', :alt => '画像'), class: "rounded-circle mx-auto mb-3 d-block" %>

となり、無事に表示させることに成功しました!

参照記事

こちらを参考にさせていただきました。

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