# Annoying problem with file\_field and paperclip

**URL:** <https://www.ruby-forum.com/t/annoying-problem-with-file-field-and-paperclip/177555>\
**Category:** Rails\
**Created:** [October 20, 2009, 5:32am UTC](https://www.ruby-forum.com/t/annoying-problem-with-file-field-and-paperclip/177555 "2009-10-20T05:32:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [October 20, 2009, 5:32am UTC](https://www.ruby-forum.com/t/annoying-problem-with-file-field-and-paperclip/177555/1 "2009-10-20T05:32:30Z")

</div>

Hi all,  
I have a really really annoying problem that’s driving me nuts with  
file\_field and paperclip and having to upload images everytime a form is  
edited even though the user is quite happy with the currently uploaded  
image or loose the previously uploaded image.

This seems to be caused by the rails file\_field helper not storing the  
data that has been read in from the db in the same way that other field  
helpers do and therfore unless an image is uploaded everytime the form  
is updated the data for the current image does not get sent back to the  
controller in the params hash.  
This in turn causes the model to believe that the data has been deleted.

This is obviously a problem with the rails helper as it should work the  
same way as all the other field helpers do and retain the data somehow  
but right now I need a work around.

Javascript is not an option as the site is a W3C AAA compliant site and  
creating a seperate form is just plain wrong as the user has enough to  
do without adding more button clicks.

Any ideas would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [October 20, 2009, 6:27pm UTC](https://www.ruby-forum.com/t/annoying-problem-with-file-field-and-paperclip/177555/2 "2009-10-20T18:27:04Z")

</div>

This doesn’t sound right at all… I’ve got many forms using form\_for  
and f.file\_field, etc… and this isn’t an issue for me. Nothing  
special I’m doing to prevent it… are you sure you’re not setting  
that field to something somewhere in a before filter or something?

---

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [October 20, 2009, 7:02pm UTC](https://www.ruby-forum.com/t/annoying-problem-with-file-field-and-paperclip/177555/3 "2009-10-20T19:02:34Z")

</div>

Philip H. wrote:

> This doesn’t sound right at all… I’ve got many forms using form\_for  
> and f.file\_field, etc… and this isn’t an issue for me. Nothing  
> special I’m doing to prevent it… are you sure you’re not setting  
> that field to something somewhere in a before filter or something?

Thanks Phillip,

Maybe it’s an issue specific to paperclip  
I’m testing on a clean app with nothing other than the crud default  
views from a scaffold plus the file\_field and the necessary paperclip  
stuff for the model.  
That maybe what I’m missing.

---

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [October 20, 2009, 11:31pm UTC](https://www.ruby-forum.com/t/annoying-problem-with-file-field-and-paperclip/177555/4 "2009-10-20T23:31:33Z")

</div>

Philip H. wrote:

> > Philip H. wrote:
> > 
> > > This doesn’t sound right at all… I’ve got many forms using form\_for  
> > > and f.file\_field, etc… and this isn’t an issue for me. Nothing  
> > > special I’m doing to prevent it… are you sure you’re not setting  
> > > that field to something somewhere in a before filter or something?
> > 
> > Thanks Phillip,
> > 
> > Maybe it’s an issue specific to paperclip
> 
> Sorry, I wasn’t clear… I too am using paperclip…
> 
> > I’m testing on a clean app with nothing other than the crud default  
> > views from a scaffold plus the file\_field and the necessary paperclip  
> > stuff for the model.  
> > That maybe what I’m missing.
> 
> Yep. Same here.

Thanks again.  
This is most strange but the problem has just dissapeared.  
I don’t understand what has happened.  
I have checked the diffs in my sourcecode repository and reversed the  
latest changes and the problem still hasn’t come back.

I’ll just have to put this down to one of those weird anomolies.  
It’s great to have confirmation that all should work properly.

Cheers

---

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [October 20, 2009, 7:31pm UTC](https://www.ruby-forum.com/t/annoying-problem-with-file-field-and-paperclip/177555/5 "2009-10-20T19:31:28Z")

</div>

> Philip H. wrote:
> 
> > This doesn’t sound right at all… I’ve got many forms using form\_for  
> > and f.file\_field, etc… and this isn’t an issue for me. Nothing  
> > special I’m doing to prevent it… are you sure you’re not setting  
> > that field to something somewhere in a before filter or something?
> 
> Thanks Phillip,
> 
> Maybe it’s an issue specific to paperclip

Sorry, I wasn’t clear… I too am using paperclip…

> I’m testing on a clean app with nothing other than the crud default  
> views from a scaffold plus the file\_field and the necessary paperclip  
> stuff for the model.  
> That maybe what I’m missing.

Yep. Same here.
