3
8

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.

【Refile】attachment_image_tag の書き方

Last updated at Posted at 2021-03-22

attachment_image_tagの書き方

<%= attachment_image_tag 保存先インスタンス名, :保存先カラム名, :fill, 幅, 高さ, format:'拡張子', fallback:"代替画像" %>

例えば、
<%= attachment_image_tag post_image.user, :profile_image, :fill, 100, 100, format:'jpg', fallback:"no_image.jpg"

*fillでうまく表示されない場合は、sizeでサイズを指定
:fill, 幅, 高さsize: "幅x高さ"

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?