From 17ffc687b9110d64f3ecd6fdf02f2f3d9c8b97f5 Mon Sep 17 00:00:00 2001 From: Nishat Date: Fri, 31 May 2013 12:18:37 +1000 Subject: [PATCH 1/2] exposed multiple files selection for upload set the multiple flag to true and modified controller to read the upload data correctly. This change will allow user to select more than one file when they use 'Add Files' button. --- app/controllers/uploads_controller.rb | 6 +++++- app/views/uploads/index.html.erb | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 4f7ea64..9e0ac65 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -40,8 +40,12 @@ def edit # POST /uploads # POST /uploads.json def create - @upload = Upload.new(params[:upload]) + # because of multiple flag set to true, + # form post is sending data in slightly nested format + # lets bring this to the front + upload_data = { "upload" => params[:upload]["upload"][0] } + @upload = Upload.new(upload) respond_to do |format| if @upload.save format.html { diff --git a/app/views/uploads/index.html.erb b/app/views/uploads/index.html.erb index 36c1bcc..80d2bdb 100644 --- a/app/views/uploads/index.html.erb +++ b/app/views/uploads/index.html.erb @@ -8,7 +8,8 @@ Add files... - <%= f.file_field :upload %> + + <%= f.file_field :upload, :multiple=>true %>