This project is archived and is in readonly mode.
Fail to send multiple files
Reported by phlawski | February 17th, 2009 @ 02:32 PM
When i tried to upload few images to server on new Rails 2.3.0 RC i found that some of my params just disappears. Here is what i have in controller:
def new
@hotel = Hotel.new
(1..8).each { @hotel.hotel_images.build }
end
def create
p params # Just for testing purposes
end
And here is my simple form:
<% form_for @hotel, :html => {:multipart => true} do |f| %>
<% f.fields_for :hotel_images do |hi| %>
<%= hi.file_field :image %>
<br />
<% end %
<% end %>
Sending empty form results in such params[:hotel] hash:
{ "hotel_images_attributes"=>{
"new_1"=>{"image"=>nil},
"new_2"=>{"image"=>nil},
"new_3"=>{"image"=>nil},
"new_4"=>{"image"=>nil},
"new_5"=>{"image"=>nil},
"new_6"=>{"image"=>nil},
"new_7"=>{"image"=>nil},
"new_8"=>{"image"=>nil}
} }
When i put one file in "slot" one named hotel[hotel_images_attributes][new_1][image] my params[:hotel][hotel_images_attributes] hash looks like:
"hotel_images_attributes"=>{ "new_1"=>{"image"=>#<File:/tmp/RackMultipart.22893.7>}, "new_3"=>{"image"=>nil}, "new_4"=>{"image"=>nil}, "new_5"=>{"image"=>nil}, "new_6"=>{"image"=>nil}, "new_7"=>{"image"=>nil}, "new_8"=>{"image"=>nil}}
so, somewhere new_2 key with values disappears. What interesting - when i put two files, on "new_1" and "new_2", then after upload there is no "new_3" and "new_4" and so on.. So, multiple files upload is impossible, because only one file is sent at all. But - funny thing is that when i put files on "new_1", "new_3" and for example "new_5" - whole bulk of files is sent properly, but ofcourse in resulting params hash there is no keys named "new_2" and "new_4" - so if there had been files they wouldn't have been available after transfer.
I tested this on Rails 2.3.0 RC using mongrel and thin on both - firefox and opera.
Comments and changes to this ticket
-
josh February 17th, 2009 @ 03:58 PM
- Milestone cleared.
- Assigned user set to josh
- State changed from new to duplicate
This was know problem on the RC1 release. Please test again on master.
-
phlawski February 17th, 2009 @ 08:31 PM
I just tried it on rails edge (rake rails:freeze:edge) and there is the same behaviour.
-
phlawski February 17th, 2009 @ 08:43 PM
Oh, nope. Sorry, it's my fault. I didn't restart rails after freeze. Everything works properly/
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>