Uploading multiple files at once to Rails app with Carrierwave (HTML5)

后端 未结 2 351
情书的邮戳
情书的邮戳 2020-12-29 14:28

I\'m close...very close...I\'m able to upload single files just fine...but when i change the type of my form\'s file_field to :multiple => true

2条回答
  •  一个人的身影
    2020-12-29 14:50

    You can do a little hack for the params array, something like:

    aux = []
    params[:gallery][:photos_attributes][:image].each do |f|
      aux << {:image => f}
    end
    params[:post][:photos_attributes] = aux
    
    @gallery = Gallery.new(params[:gallery])
    

    I have a similar problem, I know it's an ugly hack, but it works for me.

提交回复
热议问题