Skip to content

Instantly share code, notes, and snippets.

@constantm
Created August 21, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save constantm/0aa3d8398e72e4f5e7fe to your computer and use it in GitHub Desktop.
Save constantm/0aa3d8398e72e4f5e7fe to your computer and use it in GitHub Desktop.
Check whether paperclip attachment is exists in callback
In our app, we need to work out user profile completeness when a profile is saved. This is done via a callback. In this callback, we also check for the existance of Paperclip attachments.
This should supposedly be done with the following:
`@user.document.exists?`
That, however, returns false in the callback while a file is being uploaded. It looks like it's stuck in limbo between deleting the old file and saving the new one. A solution to this is to simply use the following:
`@user.document?`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment