# Keeping file field if error

**URL:** <https://www.ruby-forum.com/t/keeping-file-field-if-error/193111>\
**Category:** Rails\
**Created:** [August 11, 2010, 1:57pm UTC](https://www.ruby-forum.com/t/keeping-file-field-if-error/193111 "2010-08-11T13:57:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maese](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e56c9b/32.png) [@maese](https://www.ruby-forum.com/u/maese)\
**Post date:** [August 11, 2010, 1:57pm UTC](https://www.ruby-forum.com/t/keeping-file-field-if-error/193111/1 "2010-08-11T13:57:28Z")

</div>

hi, i’m doing a plugin for upload files, but after upload i have to  
validate some fields and if don’t pass de validation come back to the  
create page keeping the introduced dates, so the user can change the  
wrongs date without itroduce all again, my problem is that i can keep  
all the dates less the file, and i’d like keep it too, any idea?

the code of the controller for keep dates:

def new

```
@document = AlfrescoDocument.new(params[:document])
@document.project_id = @project.id
@edit_metadata = false
@file=Tempfile.new(params[:file])
@metadata = AlfrescoMetadata.new(params[:metadata])
.....

```

and in the view the file is loaded with:

\<%=l(:label\_attachment)%\>\* \<%= file\_field\_tag 'file', :size =\> 30, :id =\> nil -%\>

thanks.
