delayed_paperclip
delayed_paperclip copied to clipboard
Displaying images during processing fails
I have this Rails model with a paperclip attachment. The model looks like this:
class Photo < Asset
has_attached_file :attachment,
url: '/system/assets/:attachment/:id_partition/:style/:filename',
styles: {
medium: '640x480>',
small: '240x240#',
thumb: '48x48#'
},
default_style: :small
process_in_background :attachment
end
The problem is quite simple:
pry(main)> Photo.last.attachment.processing?
=> true
pry(main)> Photo.last.attachment.url
=> "/system/assets/attachments/000/000/001/original/photo.jpg"
Expected (according to README file):
pry(main)> Photo.last.attachment.url
=> "/images/original/missing.png"
What am I doing wrong?
You're accessing the unprocessed, original, image with attachment.url
. This will be present regardless of what processing needs to take place. If you try Photo.last.attachment.url(:thumb)
you should see the missing path returned.
However, the docs do suggest that attachment.url
will return the missing path. I'd suggest that's a mistake in the docs rather than the code.
No I have the exact same issue, Im using
Photo.last.attachment.url(:thumb)
and it returns the url of the image that is being processed, in my case Im using Amazon s3, so the result is a broken image. I even tried: processing_image_url:
however the result is the same...
@ssoulless You may have forgotten to add the <attachment>_processing
column.