When do we need to use multipart: true in Rails

Can someone tell me when and why we use multipart: true in rails.?


In the shape of

There are two attributes:
 color:string

 name : string

I want to confirm that there is no need for multipart: true, right?

+4
source share
1 answer

multipart: true used when you upload a file to your form.

Check documentationwhen downloading the file.

You can use it either form_tagexplicitly multipart: trueor simply form_for.

<%= form_tag({action: :upload}, multipart: true) do %>
  <%= file_field_tag 'picture' %>
<% end %>

<%= form_for @person do |f| %>
  <%= f.file_field :picture %>
<% end %>

In your case, you do not need it multipart: true, since you only have the colorand attributes name.

+8
source

All Articles