Skip to content

Instantly share code, notes, and snippets.

@kinopyo
Created March 28, 2012 08:52
Show Gist options
  • Save kinopyo/2224867 to your computer and use it in GitHub Desktop.
Save kinopyo/2224867 to your computer and use it in GitHub Desktop.
Check whether a Paperclip attachment exists

Check whether a Paperclip attachment exists

Don’t simply test for the presence of the magic Paperclip attribute, it will return a paperclip Attachment object and thus always be true:

- if user.photo.present? # always true
  = image_tag(user.photo.url)

Use #photo? instead:

- if user.photo?
  = image_tag(user.photo.url)
@codertcet111
Copy link

user.photo.exists? Always return me 'false', for both the cases.
It is showing me some message as, 'Digest::Digest is deprecated; use Digest', and then giving me 'false'.

@toadkicker
Copy link

user.photo_file_name.blank? is how i do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment