After banging my head against a wall wondering why certain image uploads would silently fail, while others succeeded, I stumbled across a file_column bug (and yes, I reported it).

If you have the following in your model:

validates_file_format_of :image, :in => ["bmp", "gif", "jpg", "pdf", "png"]

And you upload a file with one of these extensions in a different case, for example "SAMPLE.JPG", the file format validation fails.

Workaround (non-DRY): add case variations, like this:

validates_file_format_of :image, :in => ["bmp", "gif", "jpg", "pdf", "png", "BMP", "GIF", "JPG", "PDF", "PNG"]

Grr.

Comments

Leave a Comment


IdolHands.com Spam-o-MeterTM
Bot
Spammer
Moron
Human






* Required fields.