March 16

0 comments

You must enable html multi for file uploads.

By Christopher Mendla

March 16, 2016


Last Updated on November 30, 2019 by Christopher G Mendla

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

Christopher Mendla

About the author

Leave a Reply

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

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}