For those using JRuby. Image upload may not work with this gem.
Try the following code on JRuby:
f = File.open("test.png")
obj = f.read(f.size)
f.size and obj.size are not the same. It causes content-length and stream size not the same, and image file is corrupted.