3
3

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 5 years have passed since last update.

ActiveStorageの画像ファイルを確認画面を挟んでアップロードする方法

Posted at

はじめに

ActiveStorageの画像ファイルを確認画面を挟んでアップロードする方法

前提

Postモデルのimageにアップロードするという前提

post.rb
class Post < ApplicationRecord
  has_one_attached :image

How

_post_confirm_form.rb

# 確認画像表示

<% if @post.image.attached? %>
  <%= image_tag @post.image %>
<% end %>

# 確認画像を登録する 
<%= form.hidden_field :image, value: form.object.image.signed_id %>

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?