Rails: terminate called after throwing an instance of 'int'
Ever had the error `terminate called after throwing an instance of ‘int’` in Ruby on Rails? I have, and it’s been frustrating to no end. It was difficult to trace but eventually I found the cause. In my case it was caused by ImageScience version 1.1.3. Version 1.1.1 does not have this problem. Also, ImageMagick does not have it!
I had the exact same problem today! I was writing tests for my app and created an invalid image scenario (on purpose), just hacked up a binary file and renamed it to a jpg. ImageScience 1.1.3 does cause this error to happen.
On the other hand, I will say that ImageScience is way faster and leaner than ImageMagick, which, after years of use, I now shy away from due to memory leaks, etc.
I posted fix for this issue at http://cricketsinperil.com/2008/01/31/stricter-validation-for-rails-attachment_fu-plugin/
It uses the Unix file command to sniff the uploaded file, ensuring that it’s really an allowed content type. Might work for you if you’re on a Unix-like platform.