8

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


There are two attributes in form

 color:string

 name : string

i want to confirm that there is no need of multipart: true, right ?

Sajjad Murtaza
  • 1,444
  • 2
  • 16
  • 26
  • I don't understand at all what you are asking, please try to make it a bit more clear what you are trying to do, what you have done, what is not working and in what way we can help you. – qrikko Jan 15 '15 at 08:36

1 Answers1

15

multipart: true is used, when you have file upload in your form.

Check the documentation on file uploading.

You can go with either form_tag with explicit multipart: true or with 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 don't need multipart: true, since you only have attributes color and name.

Andrey Deineko
  • 51,333
  • 10
  • 112
  • 145