Paperclip gives error when image is not uploaded-Collection of common programming errors

The problem is that checking for @post.photo returns something that does not equal false, whatever it is. To debug this, simply print a @post.photo.inspect in your controller or view into your logfile.

Seeing that your comment already says it’s a Paperclip::Attachment object, good candidates for checking would be @post.photo.size > 0 or @post.photo.errors.empty?, or (probably best) @phost.photo.file?.

Originally posted 2013-11-09 22:39:04.