小编Bil*_*kin的帖子

Carrierwave,Rails 4和多个上传

我一直在撞墙试图让Carrierwave,Rails 4和Multiple Uploads一起工作.我可以让单个文件上传工作得很好,就像在这个和许多其他项目中一样.

这不是嵌套的情况 - 只需上传到名为Transcription的单个模型,并希望为上传的每个文档创建记录.

我似乎找不到正确的方法来声明用于载波装载的"文档"字段

mount_uploader :document, DocumentUploader
Run Code Online (Sandbox Code Playgroud)

作为要识别的强参数的数组.

我曾尝试白名单:whitelisted[:document] = params[:transcription]['document'],

将"document"声明为数组:

params.require(:transcription).permit(..... ,:document => [])

params.require(:transcription).permit(..... , { document: [] })
Run Code Online (Sandbox Code Playgroud)

这似乎更像是我为嵌套模型声明数组,但我真的希望Rails 4的强参数只是看到file_field创建的"document"数组,:multiple => true

即.从日志:form-data; name=\"transcription[document][]

有没有人在Rails 4中成功完成了多个上传,参数很强?如果是这样,请分享一下?

谢谢...

干杯,

法案

upload ruby-on-rails carrierwave

13
推荐指数
2
解决办法
8151
查看次数

标签 统计

carrierwave ×1

ruby-on-rails ×1

upload ×1