Paperclip: Adding attachment to model on update not working

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!