Thoughts, information and reflections about technology

You must enable html multi for file uploads.

I was working on an app. The app requires allowing multiple images/docs to be attached to a document.

I was getting a no method error.   I had a similar function working in another app and compared the models, databases and controllers line by line.

It turned out that the problem was with the form. You need to set an HTML multipart attribute when you call the form to upload a file or files  as in:

 

<%= form_for @document, :html => { :class => ‘form-horizontal’, multipart: true} do |f| %>

 


The upload field looks like


<%= f.label :Upload_attachments %>

<%= file_field_tag “images[]”, type: :file, multiple: true %>

This was driving me nuts for a couple of hours. It is documented in the API . Again, the multi file upload did not work until I added multipart:true in the form_for statement.

http://apidock.com/rails/ActionView/Helpers/FormTagHelper/file_field_tag

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact me
Archives
Categories
Amazon Disclosure

We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.