Skip to content

Instantly share code, notes, and snippets.

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 tombruijn/615506 to your computer and use it in GitHub Desktop.
Save tombruijn/615506 to your computer and use it in GitHub Desktop.
# Paperclip gem
# How to fix the issue with ImageMagick crashing on non-image files.
# Must be placed before has_attached_file
# Source: http://awesomeful.net/posts/33-attach-non-image-files-in-rails-with-paperclip
before_post_process :image?
def image?
!({your_model}_content_type =~ /^image.*/).nil?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment