1

I run my ruby app in development on my webserver and everything works fine. 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:

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

I use Ruby 2.3.1(p112) and Rails 5.0.

Could you please tell me whats wrong here?

Best regards

Thomas Schwärzl
  • 9,518
  • 6
  • 43
  • 69
  • Can you please share your application.html.erb file and if there is some other partial being rendered in line 18 please also the content of that file. Does it work for you when removing the explicit encoding instructions? I assume it then does. So my guess is that you are using any visible or hidden character which is not utf8 compatible. – basiszwo Jul 27 '17 at 14:09

1 Answers1

0

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.

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?

Mugur 'Bud' Chirica
  • 4,246
  • 1
  • 31
  • 34