{"id":755,"date":"2022-08-30T15:06:38","date_gmt":"2022-08-30T15:06:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/paperclip-gives-error-when-image-is-not-uploaded-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:06:38","modified_gmt":"2022-08-30T15:06:38","slug":"paperclip-gives-error-when-image-is-not-uploaded-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/paperclip-gives-error-when-image-is-not-uploaded-collection-of-common-programming-errors\/","title":{"rendered":"Paperclip gives error when image is not uploaded-Collection of common programming errors"},"content":{"rendered":"<p>The problem is that checking for <code>@post.photo<\/code> returns something that does not equal <code>false<\/code>, whatever it is. To debug this, simply print a <code>@post.photo.inspect<\/code> in your controller or view into your logfile.<\/p>\n<p>Seeing that your comment already says it&#8217;s a <code>Paperclip::Attachment<\/code> object, good candidates for checking would be <code>@post.photo.size &gt; 0<\/code> or <code>@post.photo.errors.empty?<\/code>, or (probably best) <code>@phost.photo.file?<\/code>.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:39:04. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>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&#8217;s a Paperclip::Attachment object, good candidates for checking would be @post.photo.size &gt; 0 or @post.photo.errors.empty?, or (probably [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-755","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=755"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/755\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}