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.

Similar Posts:

No tags for this post.

Leave a Reply

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

Contact me
Recent Comments