我正在尝试上传多个图像,但选择多个图像后,重新文件创建只有一个记录。我已经从那里检出了gorails refile视频,他们显示通过将image_id添加到表格来上传。但在这里refile multiple file uploads
他们正在使用Image模型。
有人能在这方面帮我吗?
下面是我的代码:
我的模型
class Photo < ActiveRecord::Base acts_as_votable attachment :image has_many :users has_many :images end
我的控制器参数
def photo_params params.require(:photo).permit(:photo_title, :photo_description,:photo_caption, :image, :image_cache_id, :remove_image,) end
照片表单视图
<%= f.attachment_field :image, direct: true, multiple: true %>
发布于 2016-05-02 18:45:11
我不能评论(没有足够的声誉),但你需要通过refile gem自述文件更详细。您的模型和contoller未设置为允许多个文件上载。
例如,你应该在你的强参数中有(image_files: []) ...
在你的照片模型中...accepts_attachments_for :images, attachment: :file
像这样的图像模型...
class Image < ActiveRecord::Base
belongs_to :photo
attachment :file
end所有内容都在自述文件中。
https://stackoverflow.com/questions/36606682
复制相似问题