ruby-on-rails – Rails 3,heroku – PGError:错误:编码“UTF8
发布时间:2020-12-17 03:19:33 所属栏目:百科 来源:网络整理
导读:我只是在heroku(postgres)上通过Rails 3随机得到这个奇怪的错误 PGError: ERROR: invalid byte sequence for encoding "UTF8": 0x85 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server,which is c
我只是在heroku(postgres)上通过Rails 3随机得到这个奇怪的错误
PGError: ERROR: invalid byte sequence for encoding "UTF8": 0x85 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server,which is controlled by "client_encoding". : INSERT INTO "comments" ("content") VALUES ('BTW∑I re-listened to the video' ...... 很好的暗示并没有为我点击任何东西.我可以在某处设置编码吗?我应该惹这个吗?有人看过这个和/或对如何处理这类问题有任何想法? 谢谢 解决方法
从我可以收集到的,这是一个问题,你试图插入PostgrSQL服务器的字符串不是用UTF-8编码的.这有点奇怪,因为您的Rails应用程序应配置为默认使用UTF-8.
有几种方法可以尝试修复此问题(按照我推荐的顺序): >首先,确保在config / application.rb中将config.encoding设置为“utf-8”. require 'base64' class Comment def content Base64::decode64(self[:content]) end def content=(value) self[:content] = Base64::encode64(value) end end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |