Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When we have to use multipart: true in Rails [duplicate]

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 ?

like image 247
Sajjad Murtaza Avatar asked Jan 15 '15 08:01

Sajjad Murtaza


1 Answers

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.

like image 191
Andrey Deineko Avatar answered Nov 15 '22 22:11

Andrey Deineko