# Paperclip: Adding attachment to model on update not working

**URL:** <https://www.ruby-forum.com/t/paperclip-adding-attachment-to-model-on-update-not-working/176159>\
**Category:** Rails\
**Created:** [September 25, 2009, 2:17pm UTC](https://www.ruby-forum.com/t/paperclip-adding-attachment-to-model-on-update-not-working/176159 "2009-09-25T14:17:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [September 25, 2009, 2:17pm UTC](https://www.ruby-forum.com/t/paperclip-adding-attachment-to-model-on-update-not-working/176159/1 "2009-09-25T14:17:44Z")

</div>

Hi,

This is a bit of a special case. Ive got a POST form for a posts model  
which has a preview functionality. So if the user clicks on “Preview”,  
then the model is saved and a new window opens with the preview. And  
the user can keep adding content to the post and previewing before  
he’s satisfied and clicks on “Publish”. And for every subsequent  
previews, i pull that original model from the DB and update it with  
the new attributes.

So when the user enters some information but does not upload an  
attachment the first time, and then clicks “Preview”, the preview  
works fine and a record is created in the DB. Now, if he adds an  
attachment and hits “Preview”, the record is pulled from the DB and  
update\_attributes is done on it. But paperclip throws an  
“ActionController::RoutingError (No route matches …” error and the  
attachment is not uploaded. I think, its looking for the original  
attachment that has to be updated.

How can I get around this issue? Any ideas?

Thanks!
