#2 √ resolved
Kamal Fariz

[PATCH] paperclip returning default url after submit

Reported by Kamal Fariz | March 27th, 2008 @ 01:26 PM

I have a page where I display the thumbnail and a file field to replace that image. After I upload a file, the app will redirect back to the same page. However, the thumbnail will be replaced with the default url. Only after I reload, the correct url is generated.

I found this was because @file was being set to nil. The patch contains a fix to assign @file from #to_io.

Second part of the patch addresses when submitting the form with other fields present, but no file selected for uploading. Paperclip will again display the default url until reloaded.

I found this was because paperclip was calling flush_write even though not required. This patch shortcircuits the generated accessor.

Comments and changes to this ticket

  • Kamal Fariz

    Kamal Fariz March 27th, 2008 @ 10:45 PM

    Hm .. the patch would break the functionality of deleting the file by setting the attachment to nil I suppose ..

    Any ideas to avoid it trampling on @file?

  • Gaius Centus Novus

    Gaius Centus Novus April 1st, 2008 @ 12:59 PM

    My [PATCH] in #5 seems to do about the same thing, though I can't say I entirely understand why. I haven't tried deleting attachments with my version.

  • Jon Yurek

    Jon Yurek April 1st, 2008 @ 01:53 PM

    • → State changed from “new” to “resolved”

    I had changed how the default attachment was being stored at one point, and didn't change it completely. Galus was closer in his fix, but the line actually needed to set @file to the default_style's file. I've committed this and it tests clean.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Tags