简体   繁体   English

Ruby on Rails在UTF-8中的无效字节序列

[英]Ruby on Rails invalid byte sequence in UTF-8

I run my ruby app in development on my webserver and everything works fine. 我在Web服务器上运行开发中的ruby应用程序,一切正常。 As soon as I deploy it to the production webserver, whichs runs with passenger I get the following error: 一旦将其部署到生产网络服务器上(随乘客一起运行),我将收到以下错误:

I, [2017-07-27T13:15:14.594740 #26105]  INFO -- : [3cbea21c-5d64-41ba-ac9e-69887cc9ebef] Started GET "/" for 92.50.69.170 at 2017-07-27 13:15:14 +0200

I, [2017-07-27T13:15:14.597422 #26105]  INFO -- : [3cbea21c-5d64-41ba-ac9e-69887cc9ebef] Processing by NewsController#index as HTML

I, [2017-07-27T13:15:14.605119 #26105]  INFO -- : [3cbea21c-5d64-41ba-ac9e-69887cc9ebef]   Rendering news/index.html.erb within layouts/application

I, [2017-07-27T13:15:14.606419 #26105]  INFO -- : [3cbea21c-5d64-41ba-ac9e-69887cc9ebef]   Rendered news/index.html.erb within layouts/application (1.0ms)

> I, [2017-07-27T13:15:14.650500 #26105]  INFO -- : [3cbea21c-5d64-41ba-ac9e-69887cc9ebef] Completed 500 Internal Server Error in 53ms (ActiveRecord: 0.0ms)

F, [2017-07-27T13:15:14.652101 #26105] FATAL -- : [3cbea21c-5d64-41ba-ac9e-69887cc9ebef]   

F, [2017-07-27T13:15:14.652170 #26105] FATAL -- : [3cbea21c-5d64-41ba-ac9e-69887cc9ebef] ActionView::Template::Error (invalid byte sequence in UTF-8):

F, [2017-07-27T13:15:14.652565 #26105] FATAL -- : [3cbea21c-5d64-41ba-ac9e-69887cc9ebef]     15: 
[3cbea21c-5d64-41ba-ac9e-69887cc9ebef]     16: 
[3cbea21c-5d64-41ba-ac9e-69887cc9ebef]     17: 
[3cbea21c-5d64-41ba-ac9e-69887cc9ebef]     18:   <%= stylesheet_link_tag    'application', media: 'all', "data-turbolinks-track" => true %>
[3cbea21c-5d64-41ba-ac9e-69887cc9ebef]     19: 
[3cbea21c-5d64-41ba-ac9e-69887cc9ebef]     20:   <%= javascript_include_tag 'application', "data-turbolinks-track" => true %>
[3cbea21c-5d64-41ba-ac9e-69887cc9ebef]     21: 

F, [2017-07-27T13:15:14.652600 #26105] FATAL -- : [3cbea21c-5d64-41ba-ac9e-69887cc9ebef]   

F, [2017-07-27T13:15:14.652633 #26105] FATAL -- : [3cbea21c-5d64-41ba-ac9e-69887cc9ebef] app/views/layouts/application.html.erb:18:in `_app_views_layouts_application_html_erb__1631551722207135725_70167078217020'

All I've changed is this in the enviroment.rb file: 我所做的只是在enviroment.rb文件中进行了更改:

Encoding.default_internal = 'utf-8'
Encoding.default_external = 'utf-8'

I use Ruby 2.3.1(p112) and Rails 5.0. 我使用Ruby 2.3.1(p112)和Rails 5.0。

Could you please tell me whats wrong here? 你能告诉我这里怎么了吗?

Best regards 最好的祝福

Have a look at this answer, it will help you understand how you can debug using a Ruby debugger and you will be able to understand what is your issue easier. 看看这个答案,它将帮助您了解如何使用Ruby调试器进行调试,并且您将能够更轻松地了解问题所在。

How to debug your code 如何调试代码

From the looks of it you have some code in your view that is not UTF-8 compatible, probably from your database? 从外观上看,您的视图中有一些不兼容UTF-8的代码,可能是数据库中的代码?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM