I use only one controller, no associations (mine only for uploading several images to the gallery), but I managed to do what you ask. You will need to adapt it to work with your relationship, but it works fine for me (although it doesnβt work in IE), I am sure that it violates some rail conventions, although this is the only way I could build functionality.
The first step is to set the upload field to receive multiple files using the HTML5 tag:
<%= f.file_field :photo, multiple: 'multiple' %>
Or if you use simple_form like me:
<%= f.input :photo, input_html: { multiple: 'multiple' } %>
The next step is to modify the create controller to accept and process multiple files. It's a bit, I'm sure some will mind, but hey, it works!
def create params[:photo][:photo].each do |photo| @params = {} @params['photo'] = photo @photo = Photo.new(@params) if !@photo.save respond_to do |format| format.html { redirect_to new_photo_path, error: 'An error occured uploading.' } end end end respond_to do |format| format.html { redirect_to photos_path, notice: 'Photos were successfully uploaded.' } end end
This is simpler than it sounds - for me the name of the controller is photo , as well as the name of the field that explains params[:photo][:photo] . Basically, it just takes the attribute :photo request (where the controller usually expects one file) and iterates over the files that were uploaded, creating a new photo for each and setting the photo @params attribute for each file, in turn, trying to save it as new photo and error notification, otherwise as soon as it is completed, it will be redirected to show photos.
As I said, this works great for me, and I hope this is also useful for you :)
Edit If this does not help, can you tell me why? Just ignoring the message after someone has taken the time to help will not make other people want to help you.