Victor S
Victor S

Reputation: 5142

Getting this error in rails: `ActionView::Template::Error (code converter not found (UTF-8 to UTF-16))`

I've started getting the following error in one of my views for some reason, I don't get it in development, but only in production.

Here is a snippet of the backtrace, any ideas?

ActionView::Template::Error (code converter not found (UTF-8 to UTF-16)):
    19:         [title, summary.gsub(/^/, "  "), nil].join("\n\n")
    20:       end
    21:     end.join
    22:     sections = sections.force_encoding('UTF-8').encode('UTF-16', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
    23: %>
    24: 
    25: <%= raw sections %>

Upvotes: 2

Views: 885

Answers (2)

Victor S
Victor S

Reputation: 5142

After some fiddling, I traced the problem to included javascrips in my view, based on conditionals, which had to manually be listed in rails configuration in order to be put through the asset pipeline.

The relevant info from Rails Guides is:

If you have other manifests or individual stylesheets and JavaScript files to include, you can add them to the precompile array:

config.assets.precompile += ['admin.js', 'admin.css', 'swfObject.js']

in production.rb

# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# config.assets.precompile += %w( search.js )

Upvotes: 1

Matt Arr
Matt Arr

Reputation: 1

I just spent my 4 hours trying to debug this exact same error message.

Are you using the workless gem ?

https://github.com/lostboy/workless

or any other kind of DelayedJob::Scaler?

Removing this gem fixed everything!

Upvotes: 0

Related Questions