Check If Item Has Attachment With Paperclip

Posted by Weston Ganger

Initially I was using:

if @post.image == ""

This will always return false with paperclip because the value will never be nil due the fact of the default_url missing.png

Instead you can check the following way:

if @post.image?


if @post.image.exists?

Article Topic:Software Development - Rails

Date:July 07, 2014

Recommended Posts



Send Me A Message

I would love to get in touch and talk about your next project. Feel free to send a message and I will get back to you shortly.

Get Connected