Status code 422 Unprocessable Entity - Paperclip, ImageMagick & Rails 3

倾然丶 夕夏残阳落幕 提交于 2019-12-04 19:41:44

Rails returning status code 422 means that validation failed so you are probably validating the upload's content type but it's always application/octet-stream because whatever you are uploading with isn't setting it properly.

You can use the mime-types gem to fix this but ideally you would fix the uploading code to correctly set the mime type.

mime_types = MIME::Types.type_for(params[:file])
file.content_type = mime_types.first.to_s if mime_types.first
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!