carrierwaveで画像をアップロードしたいのですが、画像をポリモフィック関連としているためかうまく保存できません。
Imageモデル class Image < ApplicationRecord belongs_to :imageable, :polymorphic => true mount_uploader :content, ImageUploader end Userモデル class User < ApplicationRecord has_many :images, as: :imageable end
```
Form
= form_for @user do |f|
.field
= f.label :自己紹介
= f.text_field :introduction
introduction
= fields_for @image do |ff|
= ff.file_field :content
= f.submit "保存"
よろしくお願いします。
あなたの回答
tips
プレビュー