Forum: Ruby on Rails file_column error: StringIO Instead of Temp_File

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
72f8ab180f81f9c544e2b58da399c0be?d=identicon&s=25 Elad Meidar (eizesus)
on 2006-12-31 00:36
(Received via mailing list)
Hi all,

i am using file_column to upload 3 images from the same form, they are
all different names and DOM IDs so there isn't a problem with the
multiple upload.
The problem is when i try to upload a file (or 2, or 3) sometimes it
works, but sometimes i get this in the log file:

"bar_image"=>{"file_temp"=>"", "file"=>#<StringIO:0xb4b08268>}

and the picture is not saved.

the pictures i upload are 60x60 and there is no file_column validations
or limitations at all.
when uploading larger images (500x500 for ex.) it works.

anyone?
Af9a9013100ddf2dbb0ca13487b60f8b?d=identicon&s=25 ivor (Guest)
on 2007-02-01 10:22
(Received via mailing list)
Hi.
I am getting a similar problem.

I did an svn install of file_column in my vendor directory,

I have the following code in my model:

class FileUpload < ActiveRecord::Base
  file_column :path
end

"path" is :text db is mysql

in my controller:
  def do_upload_file
    fileRecord = FileUpload.new(:path => params[:path])
    fileRecord.save
    redirect_to :action => index
  end

in the view:
<%= form_tag ({:action => 'do_upload_file'}, {:multipart => true})%>

    <%= file_column_field "file_upload", "path" %>
    <%= submit_tag "upload" %>
<%= end_form_tag %>

The resulting html is

<form action="/info_upload/do_upload_file" enctype="multipart/form-
data" method="post">

    <input id="file_upload_path_temp" name="file_upload[path_temp]"
type="hidden" /><input id="file_upload_path" name="file_upload[path]"
size="30" type="file" />
    <input name="commit" type="submit" value="upload" />
</form>

That is exactly what I did and nothing else.
When I upload the image the path field in the db is an empty string.
It used to NULL but then I changed the column to be not null. The /
path/tmp directory is created but there is no file in it.

I am guessing I am doing something really stupid because the plugin
seems to work fine out of the box for most people.

Would appreciate any help.

Regards
Ivor

On Dec 17 2006, 2:11 pm, "Elad Meidar - Creopolis.com"
This topic is locked and can not be replied to.