[Instantrails-users] Fw: [Rails] Mongrel errors on file upload

Bill Walton bill.walton at charter.net
Wed May 24 16:03:50 EDT 2006

Sorry for the cross-post but I wanted to ask here too since it's certainly possible that this is an InstantRails-specific problem.

----- Original Message ----- 
From: Bill Walton 
To: rails at lists.rubyonrails.org 
Sent: Wednesday, May 24, 2006 2:50 PM
Subject: [Norton AntiSpam] [Rails] Mongrel errors on file upload

I did a spike in my sandbox to make sure I understood how to do file uploads using CGI and there seems to be a problem with Mongrel.  WEBrick doesn't display the problem, but I can reproduce it everytime with Mongrel.  I'd really appreciate it if someone would try out the code below and see if they see the same thing.

The browser behavior is:
 - under IE6, a Page Not Found error
 - under Firefox, a blank white page

The display in the command window is not browser-dependent.  The error listing starts with "Error calling Dispatcher.dispatch #<TypeError: superclass mismatch for class Tempfile>".  I've included the entire error listing below.

The controller and view code is given below.

The CGI file upload delivers either an IOString or a Tempfile, depending on the size of the file being uploaded.  I'm using a 3K file to test IOString, and a 10K file to test Tempfile.  Both are XML text files.

The scenerio that produces the error is:
1) mongrel_rails start
2) launch brower and nav to http://localhost:3000/create
3) upload small file
4) upload large file

If I upload in reverse, first the large file and then the small file, everything's fine.

If I upload the small file and then the large file, Mongrel sends my browser off into the weeds and shows me the following in the command window.

C:\InstantRails-1.3\rails_apps\sandbox>mongrel_rails start
Running Mongrel server in development mode at
Server Ready.  Use CTRL-Pause/Break to quit.
Error calling Dispatcher.dispatch #<TypeError: superclass mismatch for class Tem
C:/InstantRails-1.3/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/cgi.rb:987:in `read_multipart'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/cgi.rb:984:in `read_multipart'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/cgi_ext/raw_post_data_fix.rb:20:in `initialize_query'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/cgi.rb:2270:in `initialize'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.11-mswin32/lib/mongrel/cgi.rb:41:in `initialize'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.11-mswin32/lib/mongrel/rails.rb:57:in `process'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.11-mswin32/lib/mongrel.rb:389:in `process_client'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.11-mswin32/lib/mongrel.rb:359:in `initialize'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.11-mswin32/lib/mongrel.rb:358:in `initialize'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.11-mswin32/lib/mongrel.rb:356:in `initialize'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.11-mswin32/lib/mongrel.rb:355:in `initialize'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.11-mswin32/bin/mongrel_rails:91:in `start_mongrel'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.11-mswin32/bin/mongrel_rails:144:in `run'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.11-mswin32/lib/mongrel/command.rb:163:in `run'

Here's my code.

------------  create_controller.rb  --------------
class CreateController < ApplicationController
  def index
  def read_in
    if params[:file_to_upload].instance_of?(Tempfile)
      FileUtils.copy(params[:file_to_upload].local_path, "#{RAILS_ROOT}/public/sandbox1.xml")
      @location_display = "Copied the Tempfile to sandbox1.xml"
      @location_display = "Saved the IOString to sandbox2.xml"

------------  index.rhtml  ------------
<h1>Choose the file to upload:</h1>

<%= start_form_tag({:action => 'read_in'}, :method => "POST", :multipart => true) %>
  <label>File to Upload:</label>
  <%= file_field_tag "file_to_upload" %><br/><br/>
  <%= submit_tag value="Upload" %>
<% end_form_tag %>

--------------- read_in.rhtml  --------------
<h1>File stored at:</h1>

<%=h @location_display %>


I'm running Windows XP.  I seem to be having a "blond moment" and can't remember how to check Rails / Ruby versions but am using InstantRails 1.3.

Thanks in advance to anyone who'll make the time to verify (or not) the problem I'm seeing.

Best regards,


Rails mailing list
Rails at lists.rubyonrails.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/instantrails-users/attachments/20060524/22bbb376/attachment.htm 

More information about the Instantrails-users mailing list