To save the image with the correct extension, you must specify the type of content. It's very nice to have this in your model as a method called before_validation
StringIO.open(Base64.decode64(self.photo_base64)) do |data| data.original_filename = "image_name.jpg" data.content_type = "image/jpeg" self.photo = data end
source share