# Making an object the same as is returned by file\_field\_tag

**URL:** <https://www.ruby-forum.com/t/making-an-object-the-same-as-is-returned-by-file-field-tag/127607>\
**Category:** Rails\
**Created:** [January 30, 2008, 6:43pm UTC](https://www.ruby-forum.com/t/making-an-object-the-same-as-is-returned-by-file-field-tag/127607 "2008-01-30T18:43:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [January 30, 2008, 6:43pm UTC](https://www.ruby-forum.com/t/making-an-object-the-same-as-is-returned-by-file-field-tag/127607/1 "2008-01-30T18:43:56Z")

</div>

I’m using attachment\_fu, and can make an attachment object (a Logo,  
which is basically an image file) fine using the tempfile that is  
returned from the file\_field\_tag on a form.

However, i also need to make some from some files that are saved  
locally, in my public folder. I’m making a Tempfile object using the  
local file, but when i pass it to attachment\_fu, it fails and crashes  
out.

Looking at the file i’ve made and the file that is sent back, one  
obvious difference is in the size attribute - for the working one from  
file\_field\_tag it’s sensible, for the one i make, size = 0.

At the moment i’m copying the file into /tmp and then just calling  
Tempfile.open with it. But as i said this results in a file with size  
0. Am i just making the Tempfile wrong? Can anyone tell me how to make  
a Tempfile that can be passed to attachment\_fu?

thanks  
max
