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.

Walter

On Mar 4, 2014, at 6:43 AM, Subbu Edimbeta wrote:

> Hi,
> 
> 
> 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.
> 
> 
> Thanks,
> Subbu
> 
> -- 
> Posted via http://www.ruby-forum.com/.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/5e2e947ab76977df6fa78bbb2de43961%40ruby-forum.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/83D73DBA-51AD-45B0-B9FF-9C0A52145513%40wdstudio.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to