我已经苦苦挣扎了一个星期,我正在尝试在 active_admin 中创建一个表单,用户可以在其中选择几张图片,添加描述和标题,然后提交他的表单以创建看起来像画廊的东西
到目前为止,我已经使用命令创建了两个模型:
rails g model Gallery title:string description:text
rails g model Image url:text #just in case the user has LOTS of images to upload
以下是我的模型现在的外观:
画廊.rb
class Gallery < ApplicationRecord
has_many :images
accepts_nested_attributes_for :images, allow_destroy: true
end
图片.rb
class Image < ApplicationRecord
belongs_to :gallery
mount_uploader :image, ImageUploader #Using Carrier Wave
end
管理员/gallery.rb
permit_params :title, :description, :images
form html: { multipart: true } do |f|
f.inputs do
f.input :title
f.input :description
f.input :images, as: :file, input_html: { multiple: true }
end
f.actions
end
我的问题是,即使我的“图像”表单出现,我也无法通过其他模型保存图像,在我的“公共/上传”目录中没有上传任何内容,也没有在我的数据库中写入任何内容。
我找不到任何有趣的互联网可以解决这个问题
随意要求另一个文件
欢迎任何帮助