jQuery-Fileupload-Rails 0.4.1 配 Rails 3.2.13 的坑
第一坑是 view 的 form_for 裡面的 f.file_field 自己多加了 [].
<%= f.file_field(:image, :multiple => true, :name => "product_photos[image]") %>
上面那段會產生
<input id="photo_image" multiple="multiple" name="product_photos[image][]" type="file">
要改成
<input id="photo_image" multiple="multiple" name="product_photos[image]" type="file">
第二坑是 view 部份的 js 要更動
var fu = $('#fileupload').data('fileupload'),
to
var fu = $('#fileupload').data('blueimpFileupload'),
第三坑是 controller 的 format.json 要變成
format.json {
render :json => [@photo.to_jq_upload].to_json
}
to
format.json {
render json: {files: [@photo.to_jq_upload]},
status: :created,
location: new_admin_product_photo_path(@product)
}
文件都不講的, 有夠坑 -_-