carrierwave upload Encoding::UndefinedConversionError: “\xFF” from ASCII-8BIT to UTF-8

后端 未结 2 1032
长情又很酷
长情又很酷 2021-01-12 03:03

Got this error on production but can\'t figure out where the problem is. Same request works fine on local development. But fail on production. I\'m building API for mobile c

相关标签:
2条回答
  • 2021-01-12 03:22

    According Rails 4.1 release note:

    Removed support for the encode_json hook used for encoding custom objects into JSON. This feature has been extracted into the activesupport-json_encoder gem. (Related Pull Request / More Details)

    Because activesupport doesn't encoding invalid code anymore. Add activesupport-json_encoder gem to Gemfile fix this issue.

    0 讨论(0)
  • 2021-01-12 03:37

    Just adding if it can be of help to someone who is trying to find the solution to the error , while trying to write .jpg or any image files.

    "wb" instead of "w" in File.open(filename,'wb') has solved this issue for me.

    0 讨论(0)
提交回复
热议问题