0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

railsチュートリアルを学習している時

問 image_tagで画像を表示してください

まずimege_tagってなんぞやということで検索。

image_tagとはHTMLのタグを生成するためのメゾット

らしい。

なるほど、、img以外にも画像を挿入する方法があるのか

書き方

image_tag "rails_icon.png", alt: "Rails icon", id: "pic1", class: "image"

app/assets/images配下に画像がある場合これで良いらしいが、

public配下の画像を表示する場合には、画像ファイルのパスを次のように / から記載する必要があるらしい。

image_tag "/rails_icon.png", alt: "Rails icon", id: "pic1", class: "image"

なるほど。。。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?