Multiple files upload


I am newbie to Ruby on Rails.I am trying to develop multiple files
upload sample app using any plugin with Rails 4.0 version,
but I haven’t find much information on that over the web.

So,Please suggest me or provide any info to develop it.


The simplest multiple file upload I have seen is using the
browser-native method of applying multiple: true to the file field.
(This does exclude older versions of IE, but they will simply be able to
upload a single file.)

To make this work, the form must be on the parent of the association –
so if you have a Catalog that has_many Products, you would create a
nested form on the Catalog, with accepts_nested_attributes_for :products
set on that model, and the Product would have an attachment of some sort
(Paperclip, CarrierWave, Dragonfly) to accept the file.

The other key to this trick is the naming of the field. Here’s a
copy-paste from such a field in a live application:

  <%= file_field_tag('project_assets_attributes_blob', multiple: 

true, name: “project[assets_attributes][][blob]”) %>

(Yes, I did learn why you don’t name your model Asset – please don’t
copy this exactly.)

As far as I can determine, there’s no good way to get the Rails form
view helpers to write out this name directly, so specifying it like this
makes it unambiguous what you are up to.

The only other thing you need to do is properly educate your users that
they can Shift-click to select a contiguous group of files, or
Command/Control click to select a discontiguous group.