Reputation: 618
When submitting a simple multipart form, the server crashes and displays "Internal server error". I have scaled down the form to the minimal:
<%= form_for @media_object, :html => {:multipart => true} do |f| %>
<%= f.file_field :media_object_image %>
<%= f.submit "Create!" %>
<% end %>
The log trace:
ERROR ArgumentError: unexpected prefix: {"RackMultipart"=>nil, ""=>nil} /Users/christer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tmpdir.rb:111:in `make_tmpname' /Users/christer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tmpdir.rb:129:in `create' /Users/christer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tempfile.rb:132:in `initialize' /Users/christer/.rvm/gems/ruby-2.3.0@teamhubs4/gems/rack-1.6.4/lib/rack/multipart/parser.rb:22:in `new' /Users/christer/.rvm/gems/ruby-2.3.0@teamhubs4/gems/rack-1.6.4/lib/rack/multipart/parser.rb:22:in `block in create' /Users/christer/.rvm/gems/ruby-2.3.0@teamhubs4/gems/rack-1.6.4/lib/rack/multipart/parser.rb:135:in `get_current_head_and_filename_and_content_type_and_name_and_body' /Users/christer/.rvm/gems/ruby-2.3.0@teamhubs4/gems/rack-1.6.4/lib/rack/multipart/parser.rb:59:in `block in parse' /Users/christer/.rvm/gems/ruby-2.3.0@teamhubs4/gems/rack-1.6.4/lib/rack/multipart/parser.rb:56:in `loop' /Users/christer/.rvm/gems/ruby-2.3.0@teamhubs4/gems/rack-1.6.4/lib/rack/multipart/parser.rb:56:in `parse' /Users/christer/.rvm/gems/ruby-2.3.0@teamhubs4/gems/rack-1.6.4/lib/rack/multipart.rb:25:in `parse_multipart' /Users/christer/.rvm/gems/ruby-2.3.0@teamhubs4/gems/rack-1.6.4/lib/rack/request.rb:375:in `parse_multipart' /Users/christer/.rvm/gems/ruby-2.3.0@teamhubs4/gems/rack-1.6.4/lib/rack/request.rb:207:in `POST'
Googling around turns up multipart submission problems with Rails 4.2 due to maximum number of open multipart files, but this is definitely different.
I'm running Rails 4.2.6 with Ruby 2.3.
Upvotes: 0
Views: 449
Reputation: 159
imgur
is not alone. dropbox
gem is also known to cause this. Check your Gemfile.
Upvotes: 0
Reputation: 618
Although I'm not using the imgur gem, Phil Ross put me on the right track. I do indeed extend the Array class with a to_hash method. Removing this extensions, and voila!, things work as they should.
Upvotes: 0