1
3

More than 3 years have passed since last update.

[Rails]本番環境で画像を表示させる

Posted at

こんな時

ローカル環境で表示されていた画像が本番環境で表示されない!
チーム開発中に思わぬところでつまずいたので備忘録残します。

解決方法

HamlやScssファイルの記述方法を変えるだけ。

画像はassetsのimagesに保存。

haml
# 変更前
= image_tag ('/assets/画像パス.拡張子')

# 変更後
= image_tag asset_path('画像パス.拡張子')
scss
# 変更前
background-image: url("/assets/画像パス.拡張子");

# 変更後
background-image: image-url("画像パス.拡張子");

ありがとうございました。

1
3
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
1
3