Uploading file in Rails gives String filename instead of File or StringIO object

Viewed 6374

Rails 3, JRuby 1.6.7.2

I've been trying something "elementary", just uploading a single text file via a form for processing in my app. The problem I'm seeing is that instead of a StringIO or File, I'm getting just a string of the file name.

Here's the form code

= form_tag(:controller => "api/#{CURRENT_API_VERSION}/api", :action => 'file', :method=> :post, :multipart => true) do
    = label_tag "file"
    = file_field_tag "upload[file]"
    = submit_tag 'Analyze!'

And the controller code that is just giving me @upload as a string containing the file name.

def file
        @upload = params[:upload][:file]
        render :template => 'api/file.html.haml'
      end

Running debugger in the controller gives me @upload.class = String, and it doesn't respond to any file or StringIO methods, such as read.

1 Answers
Related