Topic: setting up file_field to upload multiple files
I'm following this railscast: http://railscasts.com/episodes/381-jquery-file-upload
I want to do something similar in a form with nested attributes for uploading images. The main table is users. each has_many images. The application works fine for uploading a single file (using carrierwave).
The problem is, in the initial stages of the railscasts, changing the file_field is causing a problem.
#------------# <%= f.fields_for :images do |z| %> <fieldset> <p> <%= z.label :image_title %><br /> <%= z.text_field :image_title %> <%= z.hidden_field :image_priority, :value => '1' %> </p> <p> <%= z.file_field :image_location %> </p> </fieldset> <% end %> #------------------#
The railscast says you should add a "multiple" option to file_Field and then "hardcode" the field name. So somthing like this:
<%= z.file_field :image_location, multiple: true, name: "images[image_location]" %>
But this doesn't work. Once I change this, the image_location field in the images table is not populated. I suppose the problem is related to it being a nested form. How can I fix this? My end goal is to have a form with multiple uploads and progress bars using jquery-fileupload.
Have a nice week,